in infra/ecs-service/construct/ecs-monitor-const.ts [26:77]
constructor(scope: cdk.Construct, id: string, props: EcsMonitorProps) {
super(scope, id, props);
this.props = props;
const dashboardName = 'Dashboard';
this.dashboard = new cloudwatch.Dashboard(this, dashboardName, {
dashboardName: `${props.stackName}-${dashboardName}`,
});
this.addWidgets(new cloudwatch.SingleValueWidget({
title: `ALB-Request-Monitor`,
metrics: [
props.alb.metricRequestCount(),
props.alb.metricHttpCodeTarget(lb2.HttpCodeTarget.TARGET_2XX_COUNT),
props.alb.metricHttpCodeTarget(lb2.HttpCodeTarget.TARGET_3XX_COUNT),
props.alb.metricHttpCodeTarget(lb2.HttpCodeTarget.TARGET_4XX_COUNT),
props.alb.metricHttpCodeTarget(lb2.HttpCodeTarget.TARGET_5XX_COUNT),
],
width: 24,
height: 3
}));
const baseName = 'ALB-Request';
const alarm = this.createMetricAlarm(baseName, props.alb.metricRequestCount())
this.addWidgets(new cloudwatch.AlarmWidget({
title: baseName,
alarm: alarm,
width: 24,
height: 6
}));
this.addWidgets(
this.createWidget('ALB-Response', [props.alb.metricTargetResponseTime()], 24),
)
this.addWidgets(
this.createWidget('ECS-CPU', [props.ecsSrevice.metricCpuUtilization()], 12),
this.createWidget('ECS-Memory', [props.ecsSrevice.metricMemoryUtilization()], 12),
)
if (props.table != undefined) {
this.addWidgets(
this.createWidget('DDB-Read', [props.table.metricConsumedReadCapacityUnits()], 12),
this.createWidget('DDB-Write', [props.table.metricConsumedWriteCapacityUnits()], 12),
this.createWidget('DDB-Latency', [props.table.metricSuccessfulRequestLatency({dimensionsMap: {Operation: 'Scan'}}),
props.table.metricSuccessfulRequestLatency({dimensionsMap: {Operation: 'PutItem'}})], 12),
this.createWidget('DDB-Throttled', [props.table.metric('WriteThrottleEvents', {statistic: 'Sum', unit: cloudwatch.Unit.COUNT}),
props.table.metric('ReadThrottleEvents', {statistic: 'Sum', unit: cloudwatch.Unit.COUNT})], 12),
)
}
}