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?
Amazon CloudWatch alarms are used to notify when an error occurs with a Lambda function; this notification does not give any specifics about the error. For scenarios where you need specificity on the error in the notification, you can use a CloudWatch Logs subscription.
AWS CloudFormation invokes your Lambda function asynchronously with an event that includes a callback URL. The function is responsible for returning a response to the callback URL that indicates success or failure. For the full response syntax, see Custom resource response objects.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With