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.29.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39e2ac2bcc70b67b3a8fb28b5ff8ec1184e0236f0282e92d30def20cddb6aa7e |
|
MD5 | 33ef8e0d8b799ae22e4efff315bcfcd4 |
|
BLAKE2b-256 | bb23020808677be589b8a5761e0e3a1b52d3f3085f840467d8cff4e05b208b2a |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.29-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed7109c4d7affc434dfad201e589d5c43b970e53d8dc6c8738abaf2e0473fbe0 |
|
MD5 | c1c070a4a74fbb4da71ae2588ba8bdf9 |
|
BLAKE2b-256 | d2dbefebf847535b9a9f4d68acacccc7602406801652ee896f142bdc0bfb7798 |