Skip to content

Instantly share code, notes, and snippets.

@rfpedrosa
Last active November 27, 2019 14:14
Show Gist options
  • Save rfpedrosa/4f35cb44384e66963acacde7659b51b4 to your computer and use it in GitHub Desktop.
Save rfpedrosa/4f35cb44384e66963acacde7659b51b4 to your computer and use it in GitHub Desktop.
MyFunction-cloudformation-template.json (just DurationAlarm)
{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"Lambda resource stack creation using Amplify CLI",
"Parameters":{
"env":{
"Type":"String"
},
"monitoringTopicsAlarmsTopicArn":{
"Type":"String"
},
"maxDurationInMs":{
"Type":"String",
"Default":"maxDurationInMs",
"Description":"Acceptable time to the function execute without throw an alarm."
}
},
"Conditions":{
...
},
"Resources":{
... "DurationAlarm":{
"Type":"AWS::CloudWatch::Alarm",
"DependsOn":[
"LambdaFunction"
],
"Properties":{
"AlarmActions":[
{
"Ref":"monitoringTopicsAlarmsTopicArn"
}
],
"AlarmDescription":"Enters ALARM state because we have functions taking longer than expected. Please adjust the available lambda process time accordingly, then replay any failed events. See 'Duration' section on the following link: http://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-metrics.html for more information.",
"AlarmName":{
"Fn::Join":[
"",
[
{
"Ref":"LambdaFunction"
},
"-duration"
]
]
},
"ComparisonOperator":"GreaterThanThreshold",
"Dimensions":[
{
"Name":"FunctionName",
"Value":{
"Ref":"LambdaFunction"
}
}
],
"EvaluationPeriods":1,
"InsufficientDataActions":[
{
"Ref":"monitoringTopicsAlarmsTopicArn"
}
],
"MetricName":"Duration",
"Namespace":"AWS/Lambda",
"OKActions":[
{
"Ref":"monitoringTopicsAlarmsTopicArn"
}
],
"Period":60,
"Statistic":"Maximum",
"Threshold":{
"Ref":"maxDurationInMs"
},
"TreatMissingData":"notBreaching",
"Unit":"Milliseconds"
}
}
},
"Outputs":{
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment