How do you set an alarm for the percentage of errors experienced by a lambda in AWS?

Viewed 801

I'm trying to add a cloudwatch alarm which is triggered if the error rate experienced by a lambda passes a certain percentage threshold.

I've seen a few places that suggest taking the lambda error count and the lambda invocation count and using the metric math to do error count / invocation count.

That approach makes sense but what's the difference between doing that manual calculation above and using the average statistic for errors?

1 Answers

The average statistic is the Sum / Sample Count. Sample Count is just the number of CloudWatch data points for the metric in the period. So it will be the total number of errors, divided by the number of error metrics reported to CloudWatch. For example, if you were tracking over 10 minutes, and the metrics were reported once a minute, then Average would give you the average number of errors over those 10 minutes. None of this is taking into account the total number of Lambda invocations during that period, just the number of errors.

The average statistic gives you the average number of errors over a time period. You want the average number of errors over all invocations for a time period, so you'll have to use metric math in order to take into account 2 different metrics (Errors and Invocations).

Related