Sathya
Sathya

Reputation: 39

Lambda Duration using Cloud watch MetricFilter

I am trying to create the metric filter for the Lambda duration so that if the lambda exceeds 5-sec duration it should create an alarm:

Filter and pattern syntax - Amazon CloudWatch Logs

REPORT RequestId: 12345 Duration: 280.00 ms Billed Duration: 280 ms Memory Size: 512 MB Max Memory Used: 98 MB Init Duration: 637.73 ms

I want to filter this value.

Duration: 280.00 ms
{ $.Duration >= 200.00 }

trying with this filter it doesn't seem to work.

Upvotes: 1

Views: 1752

Answers (1)

Jan Garaj
Jan Garaj

Reputation: 28656

{ $.Duration >= 200.00 } is a JSON filter syntax, but you don't have logs in the JSON format - just plain text. In theory you can use CloudWatch Logs Insights, but it seems to be an overkill.

As Marcin has mentioned in the comment: standard Lambda CloudWatch metrics offer Duration metric - https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics.html - you can use it in the CloudWatch Alarm without any additional Lambda log processing.

Upvotes: 3

Related Questions