UNPKG

@pulumi/gcp

Version:

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

402 lines (401 loc) • 17.1 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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}} * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: AlertPolicyState, opts?: pulumi.CustomResourceOptions): 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: any): obj is AlertPolicy; /** * Control over how this alert policy's notification channels are notified. */ readonly alertStrategy: pulumi.Output<outputs.monitoring.AlertPolicyAlertStrategy | undefined>; /** * How to combine the results of multiple conditions to * determine if an incident should be opened. * Possible values are: `AND`, `OR`, `AND_WITH_MATCHING_RESOURCE`. */ readonly combiner: pulumi.Output<string>; /** * A list of conditions for the policy. The conditions are combined by * AND or OR according to the combiner field. If the combined conditions * evaluate to true, then an incident is created. A policy can have from * one to six conditions. * Structure is documented below. */ readonly conditions: pulumi.Output<outputs.monitoring.AlertPolicyCondition[]>; /** * A read-only record of the creation of the alerting policy. * If provided in a call to create or update, this field will * be ignored. * Structure is documented below. */ readonly creationRecords: pulumi.Output<outputs.monitoring.AlertPolicyCreationRecord[]>; /** * A short name or phrase used to identify the policy in * dashboards, notifications, and incidents. To avoid confusion, don't use * the same display name for multiple policies in the same project. The * name is limited to 512 Unicode characters. */ readonly displayName: pulumi.Output<string>; /** * Documentation that is included with notifications and incidents related to this policy. Best practice is for the * documentation to include information to help responders understand, mitigate, escalate, and correct the underlying * problems detected by the alerting policy. Notification channels that have limited capacity might not show this * documentation. */ readonly documentation: pulumi.Output<outputs.monitoring.AlertPolicyDocumentation | undefined>; /** * Whether or not the policy is enabled. The default is true. */ readonly enabled: pulumi.Output<boolean | undefined>; /** * The unique resource name for this policy. * Its syntax is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] */ readonly name: pulumi.Output<string>; /** * Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when * new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of * the NotificationChannel objects that are returned from the notificationChannels.list method. The syntax of the entries * in this field is 'projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]' */ readonly notificationChannels: pulumi.Output<string[] | undefined>; readonly project: pulumi.Output<string>; /** * The severity of an alert policy indicates how important incidents generated by that policy are. The severity level will * be displayed on the Incident detail page and in notifications. Possible values: ["CRITICAL", "ERROR", "WARNING"] */ readonly severity: pulumi.Output<string | undefined>; /** * This field is intended to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 * entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values * can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter. */ readonly userLabels: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Create a AlertPolicy resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: AlertPolicyArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering AlertPolicy resources. */ export interface AlertPolicyState { /** * Control over how this alert policy's notification channels are notified. */ alertStrategy?: pulumi.Input<inputs.monitoring.AlertPolicyAlertStrategy>; /** * How to combine the results of multiple conditions to * determine if an incident should be opened. * Possible values are: `AND`, `OR`, `AND_WITH_MATCHING_RESOURCE`. */ combiner?: pulumi.Input<string>; /** * A list of conditions for the policy. The conditions are combined by * AND or OR according to the combiner field. If the combined conditions * evaluate to true, then an incident is created. A policy can have from * one to six conditions. * Structure is documented below. */ conditions?: pulumi.Input<pulumi.Input<inputs.monitoring.AlertPolicyCondition>[]>; /** * A read-only record of the creation of the alerting policy. * If provided in a call to create or update, this field will * be ignored. * Structure is documented below. */ creationRecords?: pulumi.Input<pulumi.Input<inputs.monitoring.AlertPolicyCreationRecord>[]>; /** * A short name or phrase used to identify the policy in * dashboards, notifications, and incidents. To avoid confusion, don't use * the same display name for multiple policies in the same project. The * name is limited to 512 Unicode characters. */ displayName?: pulumi.Input<string>; /** * Documentation that is included with notifications and incidents related to this policy. Best practice is for the * documentation to include information to help responders understand, mitigate, escalate, and correct the underlying * problems detected by the alerting policy. Notification channels that have limited capacity might not show this * documentation. */ documentation?: pulumi.Input<inputs.monitoring.AlertPolicyDocumentation>; /** * Whether or not the policy is enabled. The default is true. */ enabled?: pulumi.Input<boolean>; /** * The unique resource name for this policy. * Its syntax is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] */ name?: pulumi.Input<string>; /** * Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when * new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of * the NotificationChannel objects that are returned from the notificationChannels.list method. The syntax of the entries * in this field is 'projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]' */ notificationChannels?: pulumi.Input<pulumi.Input<string>[]>; project?: pulumi.Input<string>; /** * The severity of an alert policy indicates how important incidents generated by that policy are. The severity level will * be displayed on the Incident detail page and in notifications. Possible values: ["CRITICAL", "ERROR", "WARNING"] */ severity?: pulumi.Input<string>; /** * This field is intended to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 * entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values * can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter. */ userLabels?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; } /** * The set of arguments for constructing a AlertPolicy resource. */ export interface AlertPolicyArgs { /** * Control over how this alert policy's notification channels are notified. */ alertStrategy?: pulumi.Input<inputs.monitoring.AlertPolicyAlertStrategy>; /** * How to combine the results of multiple conditions to * determine if an incident should be opened. * Possible values are: `AND`, `OR`, `AND_WITH_MATCHING_RESOURCE`. */ combiner: pulumi.Input<string>; /** * A list of conditions for the policy. The conditions are combined by * AND or OR according to the combiner field. If the combined conditions * evaluate to true, then an incident is created. A policy can have from * one to six conditions. * Structure is documented below. */ conditions: pulumi.Input<pulumi.Input<inputs.monitoring.AlertPolicyCondition>[]>; /** * A short name or phrase used to identify the policy in * dashboards, notifications, and incidents. To avoid confusion, don't use * the same display name for multiple policies in the same project. The * name is limited to 512 Unicode characters. */ displayName: pulumi.Input<string>; /** * Documentation that is included with notifications and incidents related to this policy. Best practice is for the * documentation to include information to help responders understand, mitigate, escalate, and correct the underlying * problems detected by the alerting policy. Notification channels that have limited capacity might not show this * documentation. */ documentation?: pulumi.Input<inputs.monitoring.AlertPolicyDocumentation>; /** * Whether or not the policy is enabled. The default is true. */ enabled?: pulumi.Input<boolean>; /** * Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when * new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of * the NotificationChannel objects that are returned from the notificationChannels.list method. The syntax of the entries * in this field is 'projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]' */ notificationChannels?: pulumi.Input<pulumi.Input<string>[]>; project?: pulumi.Input<string>; /** * The severity of an alert policy indicates how important incidents generated by that policy are. The severity level will * be displayed on the Incident detail page and in notifications. Possible values: ["CRITICAL", "ERROR", "WARNING"] */ severity?: pulumi.Input<string>; /** * This field is intended to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 * entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values * can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter. */ userLabels?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; }