Johannes Homuth
Johannes Homuth

Reputation: 21

AWS Cloudwatch - No Alarm-Mail send on lambda timeout of 15 min

i've a strange problem which I don't understand. I have created an cloudwatch alarm which should notify me on errors within an lambda execution (including timeout).

The relevant parameters of the alarm are the following:

period = "300"
datapoints_to_alarm = "1"
evaluation_periods = "1"
treat_missing_data = "notBreaching"
statistic = "Sum"
threshold = "0"
metric_name = "Errors"
namespace = "AWS/Lambda"
alarm_actions = http:// aws_sns_topic.alarm.arn

When my lambda run's into a timeout after 15 min (max Lambda execution time), no email is sent to me. When my lambda run's into a timeout after 2, 6, 10 or 14 minutes i will get the notification email as expected. Even on 14 minutes and 30 seconds, the mail is sent. Over 14:30 minutes, the metric doesn't switch to alarm state.

Does anybody know why that is happen? The datapoint (error) is shown correctly in the metric. It seems that the point (error) is set to the start date of the lambda. Might that be the problem? Because already 3 evaluations periods elapsed since lambda start? But why I get the alarm mail when it runs on timeout after 14 minutes (also more than one evaluation period).

Already asked this question in AWS Forum but no answer yet.

Can anyone suggest what I'm doing wrong?

Regards Hannes

Upvotes: 1

Views: 1161

Answers (1)

Ofir Gottesman
Ofir Gottesman

Reputation: 404

According to AWS documentation regarding Lambda function metrics, The timestamp on a metric reflects when the function was invoked. Depending on the duration of the execution, this can be several minutes before the metric is emitted.

So for example, if your function has a 15 minutes timeout, you should look at more than 15 minutes in the past for accurate metrics. Since AWS polls metrics status before sending alerts in absolute times, you should set your alarms parameter EvaluationPeriods to be higher than 1, and then set DatapointsToAlarm and Period parameters according to your lambda’s timeout and how often will you want to sample the alarm state in CloudWatch before raising notifications. More details about these parameters can be found here.

Upvotes: 2

Related Questions