private addResourceUtilization()

in source/lib/kda-monitoring.ts [140:213]


    private addResourceUtilization() {
        this.Dashboard.addWidgets(this.createMarkdownWidget('\n# Resource Utilization\n'));

        //---------------------------------------------------------------------
        const cpuUtilizationAlarm = new cw.Alarm(this, 'CpuUtilizationAlarm', {
            ...this.DEFAULT_ALARM_PROPS,
            threshold: this.CPU_UTILIZATION_THRESHOLD,
            metric: new cw.Metric({
                ...this.DEFAULT_METRIC_PROPS,
                metricName: 'cpuUtilization',
                statistic: 'Maximum'
            })
        })

        //---------------------------------------------------------------------
        const heapMemoryAlarm = new cw.Alarm(this, 'HeapMemoryAlarm', {
            ...this.DEFAULT_ALARM_PROPS,
            threshold: this.HEAP_MEMORY_THRESHOLD,
            metric: new cw.Metric({
                ...this.DEFAULT_METRIC_PROPS,
                metricName: 'heapMemoryUtilization',
                statistic: 'Maximum'
            })
        });

        //---------------------------------------------------------------------
        const gcCountRateExpression = new cw.MathExpression({
            expression: 'RATE(METRICS()) * 60',
            label: 'Old Generation GC Count Rate',
            period: this.MONITORING_PERIOD,
            usingMetrics: {
                'm1': new cw.Metric({
                    ...this.DEFAULT_METRIC_PROPS,
                    metricName: 'oldGenerationGCCount',
                    label: '',
                    statistic: 'Maximum'
                })
            }
        });

        //---------------------------------------------------------------------
        const gcPercentAlarm = new cw.Alarm(this, 'GCPercentAlarm', {
            ...this.DEFAULT_ALARM_PROPS,
            threshold: this.GARBAGE_COLLECTION_THRESHOLD,
            metric: new cw.MathExpression({
                expression: '(m1 * 100)/60000',
                label: 'Old Generation GC Time Percent',
                period: this.MONITORING_PERIOD,
                usingMetrics: {
                    'm1': new cw.Metric({
                        ...this.DEFAULT_METRIC_PROPS,
                        metricName: 'oldGenerationGCTime',
                        statistic: 'Maximum'
                    })
                }
            })
        });

        //---------------------------------------------------------------------
        const threadCountMetric = new cw.Metric({
            ...this.DEFAULT_METRIC_PROPS,
            metricName: 'threadsCount',
            statistic: 'Maximum'
        });

        //---------------------------------------------------------------------
        this.Dashboard.addWidgets(
            this.createAlarmWidget('CPU Utilization', cpuUtilizationAlarm),
            this.createAlarmWidget('Heap Memory Utilization', heapMemoryAlarm),
            this.createWidgetWithoutUnits('Thread Count', threadCountMetric),
            this.createAlarmWidget('Old Generation GC Percent (Over 1 Min)', gcPercentAlarm),
            this.createWidgetWithoutUnits('Old Generation GC Count Rate', gcCountRateExpression)
        );
    }