UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

265 lines • 10.2 kB
"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! *** 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.AlertPolicy = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * A description of the conditions under which some aspect of your system is * considered to be "unhealthy" and the ways to notify people or services * about this state. * * To get more information about AlertPolicy, see: * * * [API documentation](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies) * * How-to Guides * * [Official Documentation](https://cloud.google.com/monitoring/alerts/) * * ## Example Usage * * ### Monitoring Alert Policy Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", { * displayName: "My Alert Policy", * combiner: "OR", * conditions: [{ * displayName: "test condition", * conditionThreshold: { * filter: "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"", * duration: "60s", * comparison: "COMPARISON_GT", * aggregations: [{ * alignmentPeriod: "60s", * perSeriesAligner: "ALIGN_RATE", * }], * }, * }], * userLabels: { * foo: "bar", * }, * }); * ``` * ### Monitoring Alert Policy Evaluation Missing Data * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", { * displayName: "My Alert Policy", * combiner: "OR", * conditions: [{ * displayName: "test condition", * conditionThreshold: { * filter: "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"", * duration: "60s", * comparison: "COMPARISON_GT", * aggregations: [{ * alignmentPeriod: "60s", * perSeriesAligner: "ALIGN_RATE", * }], * evaluationMissingData: "EVALUATION_MISSING_DATA_INACTIVE", * }, * }], * userLabels: { * foo: "bar", * }, * }); * ``` * ### Monitoring Alert Policy Forecast Options * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", { * displayName: "My Alert Policy", * combiner: "OR", * conditions: [{ * displayName: "test condition", * conditionThreshold: { * filter: "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"", * duration: "60s", * forecastOptions: { * forecastHorizon: "3600s", * }, * comparison: "COMPARISON_GT", * aggregations: [{ * alignmentPeriod: "60s", * perSeriesAligner: "ALIGN_RATE", * }], * }, * }], * userLabels: { * foo: "bar", * }, * }); * ``` * ### Monitoring Alert Policy Promql Condition * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", { * displayName: "My Alert Policy", * combiner: "OR", * conditions: [{ * displayName: "test condition", * conditionPrometheusQueryLanguage: { * query: "compute_googleapis_com:instance_cpu_usage_time > 0", * duration: "60s", * evaluationInterval: "60s", * alertRule: "AlwaysOn", * ruleGroup: "a test", * }, * }], * alertStrategy: { * autoClose: "1800s", * }, * }); * ``` * ### Monitoring Alert Policy Sql Condition * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", { * displayName: "My Alert Policy", * combiner: "OR", * conditions: [{ * displayName: "minutes row count", * conditionSql: { * query: "SELECT severity, resource FROM my_project.global._Default._AllLogs WHERE severity IS NOT NULL", * minutes: { * periodicity: 600, * }, * rowCountTest: { * comparison: "COMPARISON_GT", * threshold: 0, * }, * }, * }], * }); * ``` * * ## Import * * AlertPolicy can be imported using any of these accepted formats: * * * `projects/{{project}}/alertPolicies/{{name}}` * * `{{project}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, AlertPolicy can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:monitoring/alertPolicy:AlertPolicy default projects/{{project}}/alertPolicies/{{name}} * $ pulumi import gcp:monitoring/alertPolicy:AlertPolicy default {{project}}/{{name}} * $ pulumi import gcp:monitoring/alertPolicy:AlertPolicy default {{name}} * ``` */ class AlertPolicy extends pulumi.CustomResource { /** * Get an existing AlertPolicy 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 AlertPolicy(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:monitoring/alertPolicy:AlertPolicy'; /** * Returns true if the given object is an instance of AlertPolicy. 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'] === AlertPolicy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["alertStrategy"] = state?.alertStrategy; resourceInputs["combiner"] = state?.combiner; resourceInputs["conditions"] = state?.conditions; resourceInputs["creationRecords"] = state?.creationRecords; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["displayName"] = state?.displayName; resourceInputs["documentation"] = state?.documentation; resourceInputs["enabled"] = state?.enabled; resourceInputs["name"] = state?.name; resourceInputs["notificationChannels"] = state?.notificationChannels; resourceInputs["project"] = state?.project; resourceInputs["severity"] = state?.severity; resourceInputs["userLabels"] = state?.userLabels; } else { const args = argsOrState; if (args?.combiner === undefined && !opts.urn) { throw new Error("Missing required property 'combiner'"); } if (args?.conditions === undefined && !opts.urn) { throw new Error("Missing required property 'conditions'"); } if (args?.displayName === undefined && !opts.urn) { throw new Error("Missing required property 'displayName'"); } resourceInputs["alertStrategy"] = args?.alertStrategy; resourceInputs["combiner"] = args?.combiner; resourceInputs["conditions"] = args?.conditions; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["displayName"] = args?.displayName; resourceInputs["documentation"] = args?.documentation; resourceInputs["enabled"] = args?.enabled; resourceInputs["notificationChannels"] = args?.notificationChannels; resourceInputs["project"] = args?.project; resourceInputs["severity"] = args?.severity; resourceInputs["userLabels"] = args?.userLabels; resourceInputs["creationRecords"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(AlertPolicy.__pulumiType, name, resourceInputs, opts); } } exports.AlertPolicy = AlertPolicy; //# sourceMappingURL=alertPolicy.js.map