I would like to implement following in Serverless framework.
I have multiple services and each serverless service has multiple lambda functions. I would like to trigger the CloudWatch alarm by all Lambda functions that fails or throw exception.
Here is the code to be triggered by one lambda function:
resources:
Resources:
TopicAlarm4xx:
Type: AWS::SNS::Topic
Properties:
TopicName: error_notification_topic
LambdaAlarm4xx:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmDescription: 4xx errors detected at Lambda
Namespace: AWS/Lambda
MetricName: 4XXErrors
Statistic: Sum
Threshold: 1
ComparisonOperator: GreaterThanOrEqualToThreshold
EvaluationPeriods: 1
Period: 300
Dimensions:
- Name: LambdaName
Value: # Value: !Ref LambdaName
Ref: functionName