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.30.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7de69d62e363028c89298a7033456b4917d685e8e87d0a979ae02a5b9d6971e |
|
MD5 | 491785aa2f954f2a5a717ed57fe6cc3d |
|
BLAKE2b-256 | 66399eb7cb042032a639036a158009264c73218cda00c4f02b4a094922e2ad90 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.30-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69ab33bf6b3d689c2dc55452d82c20d2a558a47180090118c7f2b92e86827e5f |
|
MD5 | ce743e1b541cda01edf89602094144e1 |
|
BLAKE2b-256 | 324c2910499e4acf2cabae5edb541a6d7c1cbc1a00bf7a1e318cc2332ae6cab4 |