aws-cloudformation-resource-providers-logs
aws-cloudformation-resource-providers-logs copied to clipboard
AWS::Logs::MetricFilter - Dimension support
I should be able to hard code a dimension (or use Fn::Sub) to specify a Dimension value, rather than always pull it from a log line.
Use cases:
- Filtering lambda logs that don't contain the function name.
- Attributing logs to deployment environments (prod, qa, etc)
This could be easily achieved by allowing non-selectors as dimension values (strings that don't start with $)
Currently if you try do do this you get:
metricName: `MemoryUsed`,
metricValue: "$some_value",
dimensions: {
FunctionName: `${node.ref}`
},
Resource handler returned message "invalid request provided: AWS::Logs::MetricFilter. Invalid metric transformation: dimension values must be valid selector.
So instead I need to inject the lambda name into the metric name - This makes looking for the metric and reporting on it a miserable experience, but to get it to works I have to do this :
metricName: `MemoryUsed-${node.ref}`,
metricValue: "$some_value",
See https://aws.amazon.com/about-aws/whats-new/2021/05/amazon-cloudwatch-logs-announces-dimension-support-for-metric-filters/
Hi Brent, thank you for raising this issue. We understand the pain of having to use dynamic dimension values, and I have raised the same issue internally. I will keep this GitHub issue updated if there is any progress on our side. Thanks again!
Any news? Would love to have this.
Would love this :) same use-case as this guy. I am creating a custom metric/alarm for memory usage on my lambdas and I don't have a great way of identifying the different metrics (except for putting the name of the function in the metric name which is not ideal)
Another great use case for this would be for Lambda timeout metrics. When timeouts occur, a "platform log event" is emitted: 2024-04-18T19:29:10.413Z 21c2cf65-ce53-40ff-920f-720f2c52ae41 Task timed out after 3.02 seconds
.
It's easy enough to create a metric filter for Task timed out
logs, but since the function name is not included in the log (for both Plaintext and JSON formats), there is no good way to correlate a timeout to a function in CloudWatch Metrics unless you create a unique namespace for every function (not scalable). If we could just hard-code the function name as a dimension, the problem would be solved.