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.17.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a304496a3d45ea36c04512453a520af90dc5d15a74eeb037189f39f61c8c34ac |
|
MD5 | 64b38e4ba4989cfe7d12c70935bd233d |
|
BLAKE2b-256 | 6e7ed3b80da450743163b0e2aaf68237c6f543dea9553a08fff65bf575787510 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2887eafcda4d76823e372321eda4133db7fc905b0c273254afdf20d34fe4a9dd |
|
MD5 | d6b02645ae34e34bfebdddf901bee2f2 |
|
BLAKE2b-256 | 86fbb16d7c1fe582ce95abc13aa1fae61cc1e25d4e18fe62970ab38f8b91eac0 |