From aac01a83a1033aaea06dd514816165eef651e93b Mon Sep 17 00:00:00 2001 From: mark-ship-it <72764546+mark-ship-it@users.noreply.github.com> Date: Tue, 11 May 2021 11:41:31 -0700 Subject: [PATCH] option to not auto resolve events (#29) * option to not auto resolve events * mechanism to opt out of autoresolved alerts. firehose opting out --- API.md | 10 ++++++---- src/api.ts | 2 +- src/firehose.ts | 2 +- src/watchful.ts | 6 ++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/API.md b/API.md index 2a630587..b67c7c3d 100644 --- a/API.md +++ b/API.md @@ -250,15 +250,16 @@ new Watchful(scope: Construct, id: string, props?: WatchfulProps) ### Methods -#### addAlarm(alarm) +#### addAlarm(alarm, autoResolveEvents?) ```ts -addAlarm(alarm: Alarm): void +addAlarm(alarm: Alarm, autoResolveEvents?: boolean): void ``` * **alarm** ([Alarm](#aws-cdk-aws-cloudwatch-alarm)) *No description* +* **autoResolveEvents** (boolean) *No description* @@ -496,15 +497,16 @@ __Implemented by__: [Watchful](#myhelix-cdk-watchful-watchful) ### Methods -#### addAlarm(alarm) +#### addAlarm(alarm, autoResolveEvents?) ```ts -addAlarm(alarm: Alarm): void +addAlarm(alarm: Alarm, autoResolveEvents?: boolean): void ``` * **alarm** ([Alarm](#aws-cdk-aws-cloudwatch-alarm)) *No description* +* **autoResolveEvents** (boolean) *No description* diff --git a/src/api.ts b/src/api.ts index b446620c..12d689b5 100644 --- a/src/api.ts +++ b/src/api.ts @@ -2,7 +2,7 @@ import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; export interface IWatchful { addSection(title: string, options?: SectionOptions): void; - addAlarm(alarm: cloudwatch.Alarm): void; + addAlarm(alarm: cloudwatch.Alarm, autoResolveEvents?: boolean): void; addWidgets(...widgets: cloudwatch.IWidget[]): void; } diff --git a/src/firehose.ts b/src/firehose.ts index 0bf8bad1..509938be 100644 --- a/src/firehose.ts +++ b/src/firehose.ts @@ -68,7 +68,7 @@ export class WatchFirehoseService extends cdk.Construct { evaluationPeriods: 1, treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING, }); - this.watchful.addAlarm(deliveryToRedshiftSuccessAlarm); + this.watchful.addAlarm(deliveryToRedshiftSuccessAlarm, false); return { deliveryToRedshiftSuccessMetric, deliveryToRedshiftSuccessAlarm }; } private createDeliveryToRedshiftRecordsMonitor() { diff --git a/src/watchful.ts b/src/watchful.ts index 875b4725..3e5e2d92 100644 --- a/src/watchful.ts +++ b/src/watchful.ts @@ -66,10 +66,12 @@ export class Watchful extends Construct implements IWatchful { this.dash.addWidgets(...widgets); } - public addAlarm(alarm: cloudwatch.Alarm) { + public addAlarm(alarm: cloudwatch.Alarm, autoResolveEvents=true) { if (this.alarmTopic) { alarm.addAlarmAction(new cloudwatch_actions.SnsAction(this.alarmTopic)); - alarm.addOkAction(new cloudwatch_actions.SnsAction(this.alarmTopic)); + if (autoResolveEvents) { + alarm.addOkAction(new cloudwatch_actions.SnsAction(this.alarmTopic)); + } } }