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.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea2af2f676148e0946e93fc119ad4e9be263c66f9eeeaeecc3c2e94ecb2c7bd |
|
MD5 | f89796c534bcd519c686ee6234d37b5f |
|
BLAKE2b-256 | d122dc0866eef1a9b94050b04408dabf9890cc165a232962fbdf60ad983dc540 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.20-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4bc2ad7f4f0ca7290f1576baa10fe9058535f21e5f2a80f30d9cc9fa320c247 |
|
MD5 | d7d487d40aa193a1ab1354d386be5245 |
|
BLAKE2b-256 | 77a67d4078166fbbc6f38fc9ea3ee254c5d341d14d456a6111cf1483997e1117 |