How to set up an cloudwatch alarm for lambda timeout?

Viewed 754

I have a lambda created via cloudformation template, as such. I have set my memory size and timeout period. I would like to fire off an alarm , if lambda times out. I am know sure what metric name, statistics and other values to set for my alarm below

Resources: 
  someLambda:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: "MyFunct"
      Description: "..."
      MemorySize: 512
      Timeout: 500
   
 timeoutAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: "timeout"
      AlarmDescription: "Alarm if lambda times out"
      MetricName: ...
      Dimensions:
      - Name: "FunctionName"
        Value: MyFunct
      Statistic: ...
1 Answers

There is no metric for timeouts. The only way for you to do it is to setup metric filter on your function's logs, to search for timeout messages. Then on you can create an alarm based of such a filter.

Related