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.16.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05dd3544fad01895975d17a68a9cbb779336f4915f0a2462fdd68796c5f02a20 |
|
MD5 | 60fdc36f4bb85ee1f406e87e5b3042cd |
|
BLAKE2b-256 | adb25607dbd5452cf0bf57497307ef61d2467dcded54b918a2ded482549777aa |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe06e9c2fb35adaa2f109321dd61a3065e755b7c4360f81fb640873cd1a2a371 |
|
MD5 | c17f30075843c12a2f7559b8dd29e1fe |
|
BLAKE2b-256 | a5cfdb7767e80742708125dc1c9896c245afb97a76b6d8045c04a5f89d419447 |