cdk-cloudwatch-alarm-chatbot
Project description
cdk-cloudwatch-alarm-chatbot
A CDK construct which creates an SNS AWS ChatBot (Slack) integration for CloudWatch alarms.
Example
Example use of construct
import * as cdk from 'aws-cdk-lib';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import * as cloudwatch_actions from 'aws-cdk-lib/aws-cloudwatch-actions';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { CdkCloudWatchAlarmChatBot } from 'cdk-cloudwatch-alarm-chatbot';
import { Construct } from 'constructs';
export class CdkDemoStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const queue = new sqs.Queue(this, 'HelloCdkQueue', {
visibilityTimeout: cdk.Duration.seconds(300)
});
const qMetric = queue.metric('ApproximateNumberOfMessagesVisible');
const alarm = new cloudwatch.Alarm(this, 'Alarm', {
metric: qMetric,
threshold: 100,
evaluationPeriods: 3,
datapointsToAlarm: 2
});
const slackAlarmIntegration = new CdkCloudWatchAlarmChatBot(this, 'SlackIntegration', {
topicName: 'slack-alarm',
slackChannelId: 'xxx',
slackWorkSpaceId: 'yyy',
});
alarm.addAlarmAction(new cloudwatch_actions.SnsAction(slackAlarmIntegration.topic));
}
}
Test Alarm:
$ aws cloudwatch set-alarm-state --alarm-name "xxx" --state-value ALARM --state-reason "testing purposes"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cdk-cloudwatch-alarm-chatbot-1.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a98a4f764f99a773ff3dc8fe9d09c612449184258eccb4525a0981d0c519a6 |
|
MD5 | f090ffdb26b54ecfb7a0231b8944af4b |
|
BLAKE2b-256 | 97bb5d82d68970955593a58d6042230629f7c0cc876f9acf77077bc3c591bcbd |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 474591a6cfa7bc5566d16f7368e90b94576555a95f21727049203fd6ff37394b |
|
MD5 | 8363999d281fcd5f84a7577a0a2f1589 |
|
BLAKE2b-256 | bc29a8a638ea6d739ad73f43460dc88da0d8f2dfd780aaa2f9b7fb5991516b49 |