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.18.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3225cddd75ae3b8155583ccb468e3e708dadc66789fdbcff7c8c5e03b99b9f9 |
|
MD5 | bea020a2b2bbdad09478722a7fa7e76f |
|
BLAKE2b-256 | 4169caf0f6f88ef63f2c88c825194f988bc13e01245f525ba11d31942d4161ac |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.18-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19901e1aeb894dbbb3026ff3ee59299a8ebb790ec21da048043edb760fe95d95 |
|
MD5 | e1446a1c1d5bcfb0ed9f277ea0c4fc50 |
|
BLAKE2b-256 | ec6e575d886407685c15936c5aa59103dd275196e9c9fa040c959a43f3e2096f |