"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElasticSearchApiErrorRatesMetric = void 0;
const aws_cdk_lib_1 = require("aws-cdk-lib");
const _1 = require(".");
class ElasticSearchApiErrorRatesMetric {
    constructor(props) {
        var _a, _b, _c;
        const idx = (_a = props.metricIdx) !== null && _a !== void 0 ? _a : 0;
        const usingMetrics = {
            [`m2xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '2xx', '2xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
            [`m3xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '3xx', '3xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
            [`m4xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '4xx', '4xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
            [`m5xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '5xx', '5xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
        };
        this.rate4xx = new aws_cdk_lib_1.aws_cloudwatch.MathExpression({
            label: (_b = props.label) !== null && _b !== void 0 ? _b : '4xx',
            color: props.color,
            period: props.period,
            expression: `m4xx_${idx}/(m2xx_${idx} + m3xx_${idx} + m4xx_${idx} + m5xx_${idx})*100`,
            usingMetrics,
        });
        this.rate5xx = new aws_cdk_lib_1.aws_cloudwatch.MathExpression({
            label: (_c = props.label) !== null && _c !== void 0 ? _c : '5xx',
            color: props.color,
            period: props.period,
            expression: `m5xx_${idx}/(m2xx_${idx} + m3xx_${idx} + m4xx_${idx} + m5xx_${idx})*100`,
            usingMetrics,
        });
    }
}
exports.ElasticSearchApiErrorRatesMetric = ElasticSearchApiErrorRatesMetric;
