15
votes

This is the structure of CloudFormation Alarm from AWS document.

Type: "AWS::CloudWatch::Alarm"
Properties:
  ActionsEnabled: Boolean
  AlarmActions:
    - String
  AlarmDescription: String
  AlarmName: String
  ComparisonOperator: String
  Dimensions:
    - Dimension
  EvaluateLowSampleCountPercentile: String
  EvaluationPeriods: Integer
  ExtendedStatistic: String
  InsufficientDataActions:
    - String
  MetricName: String
  Namespace: String
  OKActions:
    - String
  Period: Integer
  Statistic: String
  Threshold: Double
  TreatMissingData: String
  Unit: String

However, It seems to set an alarm for the total lambda functions metric's figure, not for only specific function and I couldn't find any mention about setting an alarm for a specific function.

How could I set an alarm for a specific function?

1

1 Answers

23
votes

To alarm on a specific lambda function's metric you have to set the FunctionName dimension.

Like this for example:

  MyNewAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: "AlarmNameGoesHere"
      AlarmDescription: "Alarm if lambda errors out too many times"
      Namespace: "AWS/Lambda"
      MetricName: "Errors"
      Dimensions:
      - Name: "FunctionName"
        Value: "NameOfYourLambdaFunction"
      Statistic: "Sum"
      ComparisonOperator: "GreaterThanThreshold"
      Threshold: 0
      EvaluationPeriods: 5
      Period: 60
      TreatMissingData: "breaching"