File tree Expand file tree Collapse file tree 5 files changed +38
-56
lines changed
Expand file tree Collapse file tree 5 files changed +38
-56
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,14 @@ import { EventConsumer } from './eventConsumer';
66import { EventProducer } from './eventProducer' ;
77import { EventRouter } from './eventRouter' ;
88import { Queue } from 'aws-cdk-lib/aws-sqs' ;
9- import { EventDashboard } from './eventDashboard ' ;
10- import { EventAlarms } from './eventAlarms ' ;
9+ import { EventMonitoring } from './eventMonitoring ' ;
10+ import { consumers } from 'stream ' ;
1111
1212export class CellStack extends cdk . Stack {
1313 router : EventRouter ;
1414 producer : EventProducer ;
1515 consumers : EventConsumer [ ] = [ ] ;
16- dashboard : EventDashboard ;
17- alarms : EventAlarms ;
16+ monitoring : EventMonitoring ;
1817
1918 constructor ( scope : Construct , id : string , props ?: cdk . StackProps ) {
2019 super ( scope , id , props ) ;
@@ -42,7 +41,10 @@ export class CellStack extends cdk.Stack {
4241 } ) ;
4342
4443 // create Dashboards and Alarms
45- this . dashboard = new EventDashboard ( this , id + 'Dashboard' ) ;
46- this . alarms = new EventAlarms ( this , id + 'Alarms' ) ;
44+ this . monitoring = new EventMonitoring ( this , id + 'Dashboard' , {
45+ router : this . router ,
46+ producer : this . producer ,
47+ consumers : this . consumers
48+ } ) ;
4749 }
4850}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import * as cdk from 'aws-cdk-lib' ;
2+ import { Construct } from 'constructs' ;
3+ import { EventRouter } from './eventRouter' ;
4+ import { EventProducer } from './eventProducer' ;
5+ import { EventConsumer } from './eventConsumer' ;
6+
7+ export interface EventMonitoringProps {
8+ router : EventRouter ;
9+ producer : EventProducer ;
10+ consumers : EventConsumer [ ] ;
11+ }
12+
13+ export class EventMonitoring extends Construct {
14+ // Public properties
15+ public readonly dashboardName : string ;
16+
17+ constructor ( scope : Construct , id : string , props ?: EventMonitoringProps ) {
18+ super ( scope , id ) ;
19+
20+ // Initialize your construct logic here
21+ }
22+
23+ // Add any helper methods here
24+ }
Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ export class EventRouter extends Construct {
4343 eventPattern : { }
4444 } ) ;
4545
46- // Custom metrics for EventBridge
47- new Metric ( {
46+ // Create metrics for EventBridge
47+ const eventsProcessedMetric = new Metric ( {
4848 namespace : 'ApplicationEvents' ,
4949 metricName : 'EventsProcessed' ,
5050 dimensionsMap : {
@@ -53,7 +53,9 @@ export class EventRouter extends Construct {
5353 } ,
5454 statistic : 'Sum' ,
5555 period : Duration . minutes ( 1 )
56- } ) . createAlarm ( this , 'LowEventThroughputAlarm' , {
56+ } )
57+
58+ eventsProcessedMetric . createAlarm ( this , 'LowEventThroughputAlarm' , {
5759 evaluationPeriods : 3 ,
5860 // Tune this threshold based on your application
5961 threshold : 100 ,
@@ -124,7 +126,7 @@ export class EventRouter extends Construct {
124126 const numberOfNotificationsDelivered = topic . metricNumberOfNotificationsDelivered ( ) ;
125127 const numberOfNotificationsFailed = topic . metricNumberOfNotificationsFailed ( ) ;
126128
127- // Create alarms for important metrics
129+ // Create alarms for failed notifications
128130 numberOfNotificationsFailed . createAlarm ( stack , `${ name } FailedNotificationsAlarm` , {
129131 threshold : 1 ,
130132 evaluationPeriods : 1 ,
You can’t perform that action at this time.
0 commit comments