How to set lambda alarm for specific lambda using CloudFormation

限于喜欢 提交于 2019-12-10 15:26:19

问题


This is the structure of alarm of CloudFormation 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:


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"


来源:https://stackoverflow.com/questions/51202166/how-to-set-lambda-alarm-for-specific-lambda-using-cloudformation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!