@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
322 lines • 12.2 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Slo = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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}}
* $ terraform import google_monitoring_slo.default "{{project}} {{name}}"
* $ 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 });
}
/** @internal */
static __pulumiType = 'gcp:monitoring/slo:Slo';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
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["deletionPolicy"] = args?.deletionPolicy;
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;
//# sourceMappingURL=slo.js.map