Last active
August 10, 2023 08:44
-
-
Save ParisaTork/0827154adf74dfd434f1cd3a4b4fd433 to your computer and use it in GitHub Desktop.
Backend5xxAlarm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GuAlarm, GuStack } from '@guardian/cdk'; | |
import { Metric, ComparisonOperator } from '@aws-cdk/aws-cloudwatch'; | |
const Backend5XXAlarmThreshold = 100; | |
const Backend5XXAlarmPeriod = 1; | |
const Backend5XXConsecutivePeriod = 5; | |
const criticalAlertsTopic = sns.Topic.fromTopicArn(this, 'CriticalAlertsTopic', 'arn:aws:sns:<region>:<account-id>:Frontend-PROD-CriticalAlerts'); // modify to CODE in the meantime? I don't think we have one for CODE, so we may need to set this up | |
const alarm = new GuAlarm(stack, 'Backend5xxAlarm', { | |
app: 'rendering', | |
stack: 'frontend', | |
stage: stack.stage, | |
metric: new Metric({ | |
namespace: 'AWS/ELB', | |
metricName: 'HTTPCode_Backend_5XX', | |
dimensions: { LoadBalancerName: lb.InternalLoadBalancer }, | |
statistic: 'Sum', | |
period: cdk.Duration.minutes(Backend5XXAlarmPeriod), | |
}), | |
alarmDescription: `Alarm if 5XX backend errors are greater than ${Backend5XXAlarmThreshold} over last ${Backend5XXAlarmPeriod} seconds`, | |
threshold: Backend5XXAlarmThreshold, | |
evaluationPeriods: Backend5XXConsecutivePeriod, | |
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD, | |
alarmActions: [criticalAlertsTopic.topicArn], // Placeholder - default is set to '', but in AWS, it shows SNS topic | |
okActions: [criticalAlertsTopic.topicArn], // Placeholder - default is set to '', but in AWS, it shows SNS topic | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment