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.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39caba26284f1da0ee6ef8948e30dab0035b89688d94ad8f72d5cf0ba89f467e |
|
MD5 | 6dc9ec93e0afd88d58f3baf4030a4cbf |
|
BLAKE2b-256 | a539ae621df792d514ed77e91658610e20e49ec37cfeb86333f545194c698f11 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8dedc1cc43e7986d03916e55d87b4abf16b430563ecc20bcf82daa8b673dd68 |
|
MD5 | fc79ce0f1bd4bdb86011f76acb601665 |
|
BLAKE2b-256 | bae745616d2b84b3d9766e285609ee5b750b36f340bad686988f1da810bdc26b |