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.27.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19ba3150940f2fe8660b380d7d22f33a857995dfc562a41d8fb241c63527f42 |
|
MD5 | fa46e0457722ed236d28fba78d9ad9d0 |
|
BLAKE2b-256 | fd90b0eb076fb4c11c39acd699a04c4dd2613129886b8d9c7aac5e60630c88fc |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.27-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f0c199eae4a8cd8726f8ecd4eac8b5752d6fa6aae06b509b8a9f93a60992946 |
|
MD5 | 0acadc6d06fcff740fb1d12ce7b377df |
|
BLAKE2b-256 | 98761db3d48f433dc8d6e4ebe8513ae57a929e1673d17975c23f3c9b6122171a |