@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
248 lines • 9.05 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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlertPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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:
*
* * `{{project}}/{{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 {{project}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:monitoring/alertPolicy:AlertPolicy default "{{project}} {{name}}"
* ```
*
* ```sh
* $ 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 });
}
/**
* 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["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["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;
/** @internal */
AlertPolicy.__pulumiType = 'gcp:monitoring/alertPolicy:AlertPolicy';
//# sourceMappingURL=alertPolicy.js.map
;