0

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.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Sathya
  • 29
  • 4
  • There is already a `Duration` metric. Why do you need new one? – Marcin Jul 28 '21 at 09:05
  • I need specifically Metrics Like { $.Duration >= 50000 Ms} but my search pattern not giving any results. My requirement is like Cloud Alarm need to be created if the Lambda duration take more than 5 seconds. – Sathya Jul 28 '21 at 09:08
  • @Marcin the Regular duration Metric using the AWS/Lambda namespace where i cannnot make it to listen to 5, 10 or 30 seconds only 60 seconds or more i can set for alarm. So i am trying to filter the Duration using metric filter and create an alaram based on the metric. – Sathya Jul 28 '21 at 09:12

1 Answers1

1

{ $.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.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59