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.22.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 075484a3f6b30189491f972f355f688ff01ba960d681ed86f477d030dab2828f |
|
MD5 | 7866ee4da186b0262fd9879a6b3cc9a9 |
|
BLAKE2b-256 | bfe391df339419a51f1730440e35f5c07eb59be59443e3c570ac9a328b0d9527 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.22-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f2c703907456efc6c9df528745bbbe9df2e4c9f965d92ae173e9cd98824dae0 |
|
MD5 | d773df270aef396423527e9673a454e6 |
|
BLAKE2b-256 | f5074e5a1adb137113e6597f634f4a1fed5946026695c153351a72ef9ddfb080 |