protected addDataStreamMetrics()

in source/lib/monitoring-base.ts [47:127]


    protected addDataStreamMetrics(streamName?: string) {
        if (streamName === undefined) {
            return;
        }

        const defaultMetricProps = {
            namespace: 'AWS/Kinesis',
            period: this.MONITORING_PERIOD,
            statistic: 'Average',
            dimensions: { 'StreamName': streamName }
        };

        const defaultAlarmProps = {
            evaluationPeriods: 1,
            treatMissingData: cw.TreatMissingData.BREACHING,
            comparisonOperator: cw.ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD
        };

        this.Dashboard.addWidgets(this.createMarkdownWidget('\n# Kinesis Data Stream Metrics\n'));

        //---------------------------------------------------------------------
        const iteratorAgeAlarm = new cw.Alarm(this, 'IteratorAgeAlarm', {
            ...defaultAlarmProps,
            threshold: this.KDS_ITERATOR_AGE_THRESHOLD,
            metric: new cw.Metric({
                ...defaultMetricProps,
                statistic: 'Maximum',
                metricName: 'GetRecords.IteratorAgeMilliseconds'
            })
        });

        //---------------------------------------------------------------------
        const readProvisionedAlarm = new cw.Alarm(this, 'ReadProvisionedAlarm', {
            ...defaultAlarmProps,
            threshold: this.KDS_READ_WRITE_PROVISIONED_THRESHOLD,
            metric: new cw.Metric({ ...defaultMetricProps, metricName: 'ReadProvisionedThroughputExceeded' })
        });

        //---------------------------------------------------------------------
        const writeProvisionedAlarm = new cw.Alarm(this, 'WriteProvisionedAlarm', {
            ...defaultAlarmProps,
            threshold: this.KDS_READ_WRITE_PROVISIONED_THRESHOLD,
            metric: new cw.Metric({ ...defaultMetricProps, metricName: 'WriteProvisionedThroughputExceeded' })
        });

        //---------------------------------------------------------------------
        const putRecordAlarm = new cw.Alarm(this, 'PutRecordAlarm', {
            ...defaultAlarmProps,
            threshold: this.KDS_PUT_RECORDS_THRESHOLD,
            treatMissingData: cw.TreatMissingData.NOT_BREACHING,
            comparisonOperator: cw.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
            metric: new cw.Metric({ ...defaultMetricProps, metricName: 'PutRecord.Success' })
        });

        //---------------------------------------------------------------------
        const putRecordsAlarm = new cw.Alarm(this, 'PutRecordsAlarm', {
            ...defaultAlarmProps,
            threshold: this.KDS_PUT_RECORDS_THRESHOLD,
            treatMissingData: cw.TreatMissingData.NOT_BREACHING,
            comparisonOperator: cw.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
            metric: new cw.Metric({ ...defaultMetricProps, metricName: 'PutRecords.Success' })
        });

        //---------------------------------------------------------------------
        const getRecordsAlarm = new cw.Alarm(this, 'GetRecordsAlarm', {
            ...defaultAlarmProps,
            threshold: this.KDS_GET_RECORDS_THRESHOLD,
            comparisonOperator: cw.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
            metric: new cw.Metric({ ...defaultMetricProps, metricName: 'GetRecords.Success' })
        });

        //---------------------------------------------------------------------
        this.Dashboard.addWidgets(
            this.createAlarmWidget('Get records iterator age (Milliseconds)', iteratorAgeAlarm),
            this.createAlarmWidget('Read throughput exceeded (Percent)', readProvisionedAlarm),
            this.createAlarmWidget('Write throughput exceeded (Percent)', writeProvisionedAlarm),
            this.createAlarmWidget('Put record success (Percent)', putRecordAlarm),
            this.createAlarmWidget('Put records success (Percent)', putRecordsAlarm),
            this.createAlarmWidget('Get records success (Percent)', getRecordsAlarm)
        );
    }