"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Slo = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A Service-Level Objective (SLO) describes the level of desired good
 * service. It consists of a service-level indicator (SLI), a performance
 * goal, and a period over which the objective is to be evaluated against
 * that goal. The SLO can use SLIs defined in a number of different manners.
 * Typical SLOs might include "99% of requests in each rolling week have
 * latency below 200 milliseconds" or "99.5% of requests in each calendar
 * month return successfully."
 *
 * To get more information about Slo, see:
 *
 * * [API documentation](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services.serviceLevelObjectives)
 * * How-to Guides
 *     * [Monitoring API Documentation](https://cloud.google.com/monitoring/api/v3/)
 *     * [Service Monitoring](https://cloud.google.com/monitoring/service-monitoring)
 *
 * ## Example Usage
 *
 * ### Monitoring Slo Appengine
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = gcp.monitoring.getAppEngineService({
 *     moduleId: "default",
 * });
 * const appengSlo = new gcp.monitoring.Slo("appeng_slo", {
 *     service: _default.then(_default => _default.serviceId),
 *     sloId: "ae-slo",
 *     displayName: "Test SLO for App Engine",
 *     goal: 0.9,
 *     calendarPeriod: "DAY",
 *     basicSli: {
 *         latency: {
 *             threshold: "1s",
 *         },
 *     },
 *     userLabels: {
 *         my_key: "my_value",
 *         my_other_key: "my_other_value",
 *     },
 * });
 * ```
 * ### Monitoring Slo Request Based
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const customsrv = new gcp.monitoring.CustomService("customsrv", {
 *     serviceId: "custom-srv-request-slos",
 *     displayName: "My Custom Service",
 * });
 * const requestBasedSlo = new gcp.monitoring.Slo("request_based_slo", {
 *     service: customsrv.serviceId,
 *     sloId: "consumed-api-slo",
 *     displayName: "Test SLO with request based SLI (good total ratio)",
 *     goal: 0.9,
 *     rollingPeriodDays: 30,
 *     requestBasedSli: {
 *         distributionCut: {
 *             distributionFilter: "metric.type=\"serviceruntime.googleapis.com/api/request_latencies\" resource.type=\"api\"  ",
 *             range: {
 *                 max: 0.5,
 *             },
 *         },
 *     },
 * });
 * ```
 * ### Monitoring Slo Windows Based Good Bad Metric Filter
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const customsrv = new gcp.monitoring.CustomService("customsrv", {
 *     serviceId: "custom-srv-windows-slos",
 *     displayName: "My Custom Service",
 * });
 * const windowsBased = new gcp.monitoring.Slo("windows_based", {
 *     service: customsrv.serviceId,
 *     displayName: "Test SLO with window based SLI",
 *     goal: 0.95,
 *     calendarPeriod: "FORTNIGHT",
 *     windowsBasedSli: {
 *         windowPeriod: "400s",
 *         goodBadMetricFilter: std.join({
 *             separator: " AND ",
 *             input: [
 *                 "metric.type=\"monitoring.googleapis.com/uptime_check/check_passed\"",
 *                 "resource.type=\"uptime_url\"",
 *             ],
 *         }).then(invoke => invoke.result),
 *     },
 * });
 * ```
 * ### Monitoring Slo Windows Based Metric Mean
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const customsrv = new gcp.monitoring.CustomService("customsrv", {
 *     serviceId: "custom-srv-windows-slos",
 *     displayName: "My Custom Service",
 * });
 * const windowsBased = new gcp.monitoring.Slo("windows_based", {
 *     service: customsrv.serviceId,
 *     displayName: "Test SLO with window based SLI",
 *     goal: 0.9,
 *     rollingPeriodDays: 20,
 *     windowsBasedSli: {
 *         windowPeriod: "600s",
 *         metricMeanInRange: {
 *             timeSeries: std.join({
 *                 separator: " AND ",
 *                 input: [
 *                     "metric.type=\"agent.googleapis.com/cassandra/client_request/latency/95p\"",
 *                     "resource.type=\"gce_instance\"",
 *                 ],
 *             }).then(invoke => invoke.result),
 *             range: {
 *                 max: 5,
 *             },
 *         },
 *     },
 * });
 * ```
 * ### Monitoring Slo Windows Based Metric Sum
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const customsrv = new gcp.monitoring.CustomService("customsrv", {
 *     serviceId: "custom-srv-windows-slos",
 *     displayName: "My Custom Service",
 * });
 * const windowsBased = new gcp.monitoring.Slo("windows_based", {
 *     service: customsrv.serviceId,
 *     displayName: "Test SLO with window based SLI",
 *     goal: 0.9,
 *     rollingPeriodDays: 20,
 *     windowsBasedSli: {
 *         windowPeriod: "400s",
 *         metricSumInRange: {
 *             timeSeries: std.join({
 *                 separator: " AND ",
 *                 input: [
 *                     "metric.type=\"monitoring.googleapis.com/uptime_check/request_latency\"",
 *                     "resource.type=\"uptime_url\"",
 *                 ],
 *             }).then(invoke => invoke.result),
 *             range: {
 *                 max: 5000,
 *             },
 *         },
 *     },
 * });
 * ```
 * ### Monitoring Slo Windows Based Ratio Threshold
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const customsrv = new gcp.monitoring.CustomService("customsrv", {
 *     serviceId: "custom-srv-windows-slos",
 *     displayName: "My Custom Service",
 * });
 * const windowsBased = new gcp.monitoring.Slo("windows_based", {
 *     service: customsrv.serviceId,
 *     displayName: "Test SLO with window based SLI",
 *     goal: 0.9,
 *     rollingPeriodDays: 20,
 *     windowsBasedSli: {
 *         windowPeriod: "100s",
 *         goodTotalRatioThreshold: {
 *             threshold: 0.1,
 *             performance: {
 *                 distributionCut: {
 *                     distributionFilter: std.join({
 *                         separator: " AND ",
 *                         input: [
 *                             "metric.type=\"serviceruntime.googleapis.com/api/request_latencies\"",
 *                             "resource.type=\"consumed_api\"",
 *                         ],
 *                     }).then(invoke => invoke.result),
 *                     range: {
 *                         min: 1,
 *                         max: 9,
 *                     },
 *                 },
 *             },
 *         },
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * Slo can be imported using any of these accepted formats:
 *
 * * `{{project}}/{{name}}`
 *
 * * `{{project}} {{name}}`
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, Slo can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:monitoring/slo:Slo default {{project}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:monitoring/slo:Slo default "{{project}} {{name}}"
 * ```
 *
 * ```sh
 * $ pulumi import gcp:monitoring/slo:Slo default {{name}}
 * ```
 */
class Slo extends pulumi.CustomResource {
    /**
     * Get an existing Slo resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new Slo(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Slo.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === Slo.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["basicSli"] = state?.basicSli;
            resourceInputs["calendarPeriod"] = state?.calendarPeriod;
            resourceInputs["displayName"] = state?.displayName;
            resourceInputs["goal"] = state?.goal;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["requestBasedSli"] = state?.requestBasedSli;
            resourceInputs["rollingPeriodDays"] = state?.rollingPeriodDays;
            resourceInputs["service"] = state?.service;
            resourceInputs["sloId"] = state?.sloId;
            resourceInputs["userLabels"] = state?.userLabels;
            resourceInputs["windowsBasedSli"] = state?.windowsBasedSli;
        }
        else {
            const args = argsOrState;
            if (args?.goal === undefined && !opts.urn) {
                throw new Error("Missing required property 'goal'");
            }
            if (args?.service === undefined && !opts.urn) {
                throw new Error("Missing required property 'service'");
            }
            resourceInputs["basicSli"] = args?.basicSli;
            resourceInputs["calendarPeriod"] = args?.calendarPeriod;
            resourceInputs["displayName"] = args?.displayName;
            resourceInputs["goal"] = args?.goal;
            resourceInputs["project"] = args?.project;
            resourceInputs["requestBasedSli"] = args?.requestBasedSli;
            resourceInputs["rollingPeriodDays"] = args?.rollingPeriodDays;
            resourceInputs["service"] = args?.service;
            resourceInputs["sloId"] = args?.sloId;
            resourceInputs["userLabels"] = args?.userLabels;
            resourceInputs["windowsBasedSli"] = args?.windowsBasedSli;
            resourceInputs["name"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Slo.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Slo = Slo;
/** @internal */
Slo.__pulumiType = 'gcp:monitoring/slo:Slo';
//# sourceMappingURL=slo.js.map