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.21.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ba98ed1483ef41c1e71a8d51196d0ea666dcb8bf230156c895e87a9d9103fc1 |
|
MD5 | 773278395f4f5aa38a446d7cd20975ff |
|
BLAKE2b-256 | 1fba5a7be3b118ebea96e508cb5eb668ce021d68164c550a26360208fa487ed9 |
Close
Hashes for cdk_cloudwatch_alarm_chatbot-1.0.21-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7883d4eebbcb12d4d05bc2e0f4df46b26019cdab06a6d059b2fa405b94bd7913 |
|
MD5 | 3280746ffc7a197df2fa30ac4ba40685 |
|
BLAKE2b-256 | 4a9ad86170285e919ac2b5fd917e0bc04bbafe1f5d15461dd307861e851082d5 |