"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomAvailabilityMetric = void 0;
const aws_cdk_lib_1 = require("aws-cdk-lib");
/**
 * Creates a metric that can be used as an SLI for Custom Metrics
 * Availability SLOs
 */
class CustomAvailabilityMetric extends aws_cdk_lib_1.aws_cloudwatch.MathExpression {
    constructor(props) {
        const errors = new aws_cdk_lib_1.aws_cloudwatch.Metric({
            namespace: props.namespace,
            metricName: props.errorsMetricName,
            statistic: 'Sum',
            label: 'Errors',
        });
        const requests = new aws_cdk_lib_1.aws_cloudwatch.Metric({
            namespace: props.namespace,
            metricName: props.countsMetricName,
            statistic: 'Sum',
            label: 'Requests',
        });
        const myProps = {
            label: 'Availability',
            expression: '(requests - errors)/requests',
            usingMetrics: { requests, errors },
            period: props.sloWindow.alertWindow,
        };
        super({ ...props, ...myProps });
    }
}
exports.CustomAvailabilityMetric = CustomAvailabilityMetric;
