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.14.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 106cd76b4c9b86a7964af5b566f6d4e321ca2ebe59d8af71579fb831e164099f |
|
MD5 | 326908e378d3427ccf0f4e43b976edd2 |
|
BLAKE2b-256 | e4d02493c04ba63545b411c90898989c8b61f4809d120349b8599afa7f001d66 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 628c870fc1aba6b3db7cfe4a31a2480482fa3fbd8da7861f09063cc5db1c75a7 |
|
MD5 | 76bb8ce689f58e555b742d840c59489b |
|
BLAKE2b-256 | fef71ada8ea1ba99aa85198c7de9210127abe2bd16af18bcb80eed85ce218ad3 |