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.24.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e8fcd2e719574af7247f7736888f2f9bc90988ba244416bc35615f46143ec38 |
|
MD5 | e6ce204222eb46aa316bbe06fb6ec1aa |
|
BLAKE2b-256 | 17119605741d6b4d4dbf1415393218e93f6ef1ba200d2eebe1bfbbfb1de5066a |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.24-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bbac6b3501f9615fcc76649a7ed2615c3db69393509058430358dafdf516d34 |
|
MD5 | 5276a91407b992a7b691367f149999a5 |
|
BLAKE2b-256 | 31c9f1dbbedcc2bc65ee2b4977663eea47bb5653882a29a944c16cdaa4cc5ddf |