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.28.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b547d31157e5f9712f3b1269634bd9db283c48a547726d3e53b5b8a4346f9ae |
|
MD5 | 613d0c29f96866a49579cf93c270b54f |
|
BLAKE2b-256 | 0335545c20a8894a53ebf7979646f8155161e9b5580f8eae00dbe2c593977f5d |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.28-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 087f6b2ca7ae49a53042ad921665ffec998405b0b992bd743502ea4dba350eb5 |
|
MD5 | 543cf83fcba3695cffddbd4c12f2efe6 |
|
BLAKE2b-256 | 55ca8194584789edd70e578aa4ea93fdd9e661c9f56da87e583041ec83847c1e |