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.23.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e9fb66a6821f83a253434d005030479b218e52514beef291d3fa2882ca36185 |
|
MD5 | 71a3aaca311146797e1a881fac30a561 |
|
BLAKE2b-256 | 3f09e0b3d4dc3146c18ebed70238df3c6b7f9450677337a8a18cb51115d34296 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.23-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b4ee3ac5f96f3ff50c3302999430785f811d10933d1edfd412f65bee6c15760 |
|
MD5 | c40239e58c2b09bf286ad7fdad035d6f |
|
BLAKE2b-256 | cb50eb9b16b22d36f955ca174a92e4a02ed18e253782da18ef66ac3e8520a94d |