Search code examples
aws-lambdaamazon-cloudwatch

How to add Lambda function name as Dimension Value in AWS Metric Filter


I am trying to filter this cold start metric using the metric filter

REPORT RequestId: beae69d8-bf66-4390-845f-d995f7939bd2 Duration: 1.75 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 36 MB Init Duration: 101.97 ms

using below filter

[
  report_label=REPORT,
  request_id_label=RequestId*, request_id_value,
  duration_label=Duration*, lambda_duration_ms, duration_unit=ms,
  billed_duration_label1=Billed, bill_duration_label2=Duration*, lambda_billed_duration_ms, billed_duration_unit=ms,
  memory_size_label1=Memory, memory_size_label2=Size*, lambda_memory_size_mb, memory_size_unit=MB,
  max_memory_used_label1=Max, max_memory_used_label2=Memory, max_memory_used_label3=Used*, lambda_max_memory_used_mb, max_memory_used_unit=MB,
  init_duration_label1=Init, init_duration_label2=Duration*, lambda_init_duration_ms, init_duration_unit=ms, function_name=xxx
]

Everything works fine but the issue comes when we filter metrics for multiple lambda functions as we are not able to identify which metric belongs to which function.

is there a way to add a function name as Dimension Value?


Solution

  • At the time of writing this, it's not possible. Dimension values must be a value extracted by the filter pattern. The AWS docs aren't clear on this but if you try it the API returns the following: An error occurred (InvalidParameterException) when calling the PutMetricFilter operation: Invalid metric transformation: dimension value must be valid selector.

    Definitely frustrating for doing stuff like this since the Lambda function name isn't in that log line.