Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.monitoring.kotlin.AlertPolicyArgs.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.monitoring.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.monitoring.AlertPolicyArgs.builder
import com.pulumi.gcp.monitoring.kotlin.inputs.AlertPolicyAlertStrategyArgs
import com.pulumi.gcp.monitoring.kotlin.inputs.AlertPolicyAlertStrategyArgsBuilder
import com.pulumi.gcp.monitoring.kotlin.inputs.AlertPolicyConditionArgs
import com.pulumi.gcp.monitoring.kotlin.inputs.AlertPolicyConditionArgsBuilder
import com.pulumi.gcp.monitoring.kotlin.inputs.AlertPolicyDocumentationArgs
import com.pulumi.gcp.monitoring.kotlin.inputs.AlertPolicyDocumentationArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName
/**
* 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",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* alert_policy = gcp.monitoring.AlertPolicy("alert_policy",
* display_name="My Alert Policy",
* combiner="OR",
* conditions=[{
* "display_name": "test condition",
* "condition_threshold": {
* "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* "duration": "60s",
* "comparison": "COMPARISON_GT",
* "aggregations": [{
* "alignment_period": "60s",
* "per_series_aligner": "ALIGN_RATE",
* }],
* },
* }],
* user_labels={
* "foo": "bar",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var alertPolicy = new Gcp.Monitoring.AlertPolicy("alert_policy", new()
* {
* DisplayName = "My Alert Policy",
* Combiner = "OR",
* Conditions = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionArgs
* {
* DisplayName = "test condition",
* ConditionThreshold = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdArgs
* {
* Filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* Duration = "60s",
* Comparison = "COMPARISON_GT",
* Aggregations = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdAggregationArgs
* {
* AlignmentPeriod = "60s",
* PerSeriesAligner = "ALIGN_RATE",
* },
* },
* },
* },
* },
* UserLabels =
* {
* { "foo", "bar" },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/monitoring"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := monitoring.NewAlertPolicy(ctx, "alert_policy", &monitoring.AlertPolicyArgs{
* DisplayName: pulumi.String("My Alert Policy"),
* Combiner: pulumi.String("OR"),
* Conditions: monitoring.AlertPolicyConditionArray{
* &monitoring.AlertPolicyConditionArgs{
* DisplayName: pulumi.String("test condition"),
* ConditionThreshold: &monitoring.AlertPolicyConditionConditionThresholdArgs{
* Filter: pulumi.String("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""),
* Duration: pulumi.String("60s"),
* Comparison: pulumi.String("COMPARISON_GT"),
* Aggregations: monitoring.AlertPolicyConditionConditionThresholdAggregationArray{
* &monitoring.AlertPolicyConditionConditionThresholdAggregationArgs{
* AlignmentPeriod: pulumi.String("60s"),
* PerSeriesAligner: pulumi.String("ALIGN_RATE"),
* },
* },
* },
* },
* },
* UserLabels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.monitoring.AlertPolicy;
* import com.pulumi.gcp.monitoring.AlertPolicyArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionConditionThresholdArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var alertPolicy = new AlertPolicy("alertPolicy", AlertPolicyArgs.builder()
* .displayName("My Alert Policy")
* .combiner("OR")
* .conditions(AlertPolicyConditionArgs.builder()
* .displayName("test condition")
* .conditionThreshold(AlertPolicyConditionConditionThresholdArgs.builder()
* .filter("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"")
* .duration("60s")
* .comparison("COMPARISON_GT")
* .aggregations(AlertPolicyConditionConditionThresholdAggregationArgs.builder()
* .alignmentPeriod("60s")
* .perSeriesAligner("ALIGN_RATE")
* .build())
* .build())
* .build())
* .userLabels(Map.of("foo", "bar"))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* alertPolicy:
* type: gcp:monitoring:AlertPolicy
* name: alert_policy
* properties:
* 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",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* alert_policy = gcp.monitoring.AlertPolicy("alert_policy",
* display_name="My Alert Policy",
* combiner="OR",
* conditions=[{
* "display_name": "test condition",
* "condition_threshold": {
* "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* "duration": "60s",
* "comparison": "COMPARISON_GT",
* "aggregations": [{
* "alignment_period": "60s",
* "per_series_aligner": "ALIGN_RATE",
* }],
* "evaluation_missing_data": "EVALUATION_MISSING_DATA_INACTIVE",
* },
* }],
* user_labels={
* "foo": "bar",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var alertPolicy = new Gcp.Monitoring.AlertPolicy("alert_policy", new()
* {
* DisplayName = "My Alert Policy",
* Combiner = "OR",
* Conditions = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionArgs
* {
* DisplayName = "test condition",
* ConditionThreshold = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdArgs
* {
* Filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* Duration = "60s",
* Comparison = "COMPARISON_GT",
* Aggregations = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdAggregationArgs
* {
* AlignmentPeriod = "60s",
* PerSeriesAligner = "ALIGN_RATE",
* },
* },
* EvaluationMissingData = "EVALUATION_MISSING_DATA_INACTIVE",
* },
* },
* },
* UserLabels =
* {
* { "foo", "bar" },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/monitoring"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := monitoring.NewAlertPolicy(ctx, "alert_policy", &monitoring.AlertPolicyArgs{
* DisplayName: pulumi.String("My Alert Policy"),
* Combiner: pulumi.String("OR"),
* Conditions: monitoring.AlertPolicyConditionArray{
* &monitoring.AlertPolicyConditionArgs{
* DisplayName: pulumi.String("test condition"),
* ConditionThreshold: &monitoring.AlertPolicyConditionConditionThresholdArgs{
* Filter: pulumi.String("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""),
* Duration: pulumi.String("60s"),
* Comparison: pulumi.String("COMPARISON_GT"),
* Aggregations: monitoring.AlertPolicyConditionConditionThresholdAggregationArray{
* &monitoring.AlertPolicyConditionConditionThresholdAggregationArgs{
* AlignmentPeriod: pulumi.String("60s"),
* PerSeriesAligner: pulumi.String("ALIGN_RATE"),
* },
* },
* EvaluationMissingData: pulumi.String("EVALUATION_MISSING_DATA_INACTIVE"),
* },
* },
* },
* UserLabels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.monitoring.AlertPolicy;
* import com.pulumi.gcp.monitoring.AlertPolicyArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionConditionThresholdArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var alertPolicy = new AlertPolicy("alertPolicy", AlertPolicyArgs.builder()
* .displayName("My Alert Policy")
* .combiner("OR")
* .conditions(AlertPolicyConditionArgs.builder()
* .displayName("test condition")
* .conditionThreshold(AlertPolicyConditionConditionThresholdArgs.builder()
* .filter("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"")
* .duration("60s")
* .comparison("COMPARISON_GT")
* .aggregations(AlertPolicyConditionConditionThresholdAggregationArgs.builder()
* .alignmentPeriod("60s")
* .perSeriesAligner("ALIGN_RATE")
* .build())
* .evaluationMissingData("EVALUATION_MISSING_DATA_INACTIVE")
* .build())
* .build())
* .userLabels(Map.of("foo", "bar"))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* alertPolicy:
* type: gcp:monitoring:AlertPolicy
* name: alert_policy
* properties:
* 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",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* alert_policy = gcp.monitoring.AlertPolicy("alert_policy",
* display_name="My Alert Policy",
* combiner="OR",
* conditions=[{
* "display_name": "test condition",
* "condition_threshold": {
* "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* "duration": "60s",
* "forecast_options": {
* "forecast_horizon": "3600s",
* },
* "comparison": "COMPARISON_GT",
* "aggregations": [{
* "alignment_period": "60s",
* "per_series_aligner": "ALIGN_RATE",
* }],
* },
* }],
* user_labels={
* "foo": "bar",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var alertPolicy = new Gcp.Monitoring.AlertPolicy("alert_policy", new()
* {
* DisplayName = "My Alert Policy",
* Combiner = "OR",
* Conditions = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionArgs
* {
* DisplayName = "test condition",
* ConditionThreshold = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdArgs
* {
* Filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* Duration = "60s",
* ForecastOptions = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdForecastOptionsArgs
* {
* ForecastHorizon = "3600s",
* },
* Comparison = "COMPARISON_GT",
* Aggregations = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdAggregationArgs
* {
* AlignmentPeriod = "60s",
* PerSeriesAligner = "ALIGN_RATE",
* },
* },
* },
* },
* },
* UserLabels =
* {
* { "foo", "bar" },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/monitoring"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := monitoring.NewAlertPolicy(ctx, "alert_policy", &monitoring.AlertPolicyArgs{
* DisplayName: pulumi.String("My Alert Policy"),
* Combiner: pulumi.String("OR"),
* Conditions: monitoring.AlertPolicyConditionArray{
* &monitoring.AlertPolicyConditionArgs{
* DisplayName: pulumi.String("test condition"),
* ConditionThreshold: &monitoring.AlertPolicyConditionConditionThresholdArgs{
* Filter: pulumi.String("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""),
* Duration: pulumi.String("60s"),
* ForecastOptions: &monitoring.AlertPolicyConditionConditionThresholdForecastOptionsArgs{
* ForecastHorizon: pulumi.String("3600s"),
* },
* Comparison: pulumi.String("COMPARISON_GT"),
* Aggregations: monitoring.AlertPolicyConditionConditionThresholdAggregationArray{
* &monitoring.AlertPolicyConditionConditionThresholdAggregationArgs{
* AlignmentPeriod: pulumi.String("60s"),
* PerSeriesAligner: pulumi.String("ALIGN_RATE"),
* },
* },
* },
* },
* },
* UserLabels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.monitoring.AlertPolicy;
* import com.pulumi.gcp.monitoring.AlertPolicyArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionConditionThresholdArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionConditionThresholdForecastOptionsArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var alertPolicy = new AlertPolicy("alertPolicy", AlertPolicyArgs.builder()
* .displayName("My Alert Policy")
* .combiner("OR")
* .conditions(AlertPolicyConditionArgs.builder()
* .displayName("test condition")
* .conditionThreshold(AlertPolicyConditionConditionThresholdArgs.builder()
* .filter("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"")
* .duration("60s")
* .forecastOptions(AlertPolicyConditionConditionThresholdForecastOptionsArgs.builder()
* .forecastHorizon("3600s")
* .build())
* .comparison("COMPARISON_GT")
* .aggregations(AlertPolicyConditionConditionThresholdAggregationArgs.builder()
* .alignmentPeriod("60s")
* .perSeriesAligner("ALIGN_RATE")
* .build())
* .build())
* .build())
* .userLabels(Map.of("foo", "bar"))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* alertPolicy:
* type: gcp:monitoring:AlertPolicy
* name: alert_policy
* properties:
* 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",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* alert_policy = gcp.monitoring.AlertPolicy("alert_policy",
* display_name="My Alert Policy",
* combiner="OR",
* conditions=[{
* "display_name": "test condition",
* "condition_prometheus_query_language": {
* "query": "compute_googleapis_com:instance_cpu_usage_time > 0",
* "duration": "60s",
* "evaluation_interval": "60s",
* "alert_rule": "AlwaysOn",
* "rule_group": "a test",
* },
* }],
* alert_strategy={
* "auto_close": "1800s",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var alertPolicy = new Gcp.Monitoring.AlertPolicy("alert_policy", new()
* {
* DisplayName = "My Alert Policy",
* Combiner = "OR",
* Conditions = new[]
* {
* new Gcp.Monitoring.Inputs.AlertPolicyConditionArgs
* {
* DisplayName = "test condition",
* ConditionPrometheusQueryLanguage = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionPrometheusQueryLanguageArgs
* {
* Query = "compute_googleapis_com:instance_cpu_usage_time > 0",
* Duration = "60s",
* EvaluationInterval = "60s",
* AlertRule = "AlwaysOn",
* RuleGroup = "a test",
* },
* },
* },
* AlertStrategy = new Gcp.Monitoring.Inputs.AlertPolicyAlertStrategyArgs
* {
* AutoClose = "1800s",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/monitoring"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := monitoring.NewAlertPolicy(ctx, "alert_policy", &monitoring.AlertPolicyArgs{
* DisplayName: pulumi.String("My Alert Policy"),
* Combiner: pulumi.String("OR"),
* Conditions: monitoring.AlertPolicyConditionArray{
* &monitoring.AlertPolicyConditionArgs{
* DisplayName: pulumi.String("test condition"),
* ConditionPrometheusQueryLanguage: &monitoring.AlertPolicyConditionConditionPrometheusQueryLanguageArgs{
* Query: pulumi.String("compute_googleapis_com:instance_cpu_usage_time > 0"),
* Duration: pulumi.String("60s"),
* EvaluationInterval: pulumi.String("60s"),
* AlertRule: pulumi.String("AlwaysOn"),
* RuleGroup: pulumi.String("a test"),
* },
* },
* },
* AlertStrategy: &monitoring.AlertPolicyAlertStrategyArgs{
* AutoClose: pulumi.String("1800s"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.monitoring.AlertPolicy;
* import com.pulumi.gcp.monitoring.AlertPolicyArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionConditionPrometheusQueryLanguageArgs;
* import com.pulumi.gcp.monitoring.inputs.AlertPolicyAlertStrategyArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var alertPolicy = new AlertPolicy("alertPolicy", AlertPolicyArgs.builder()
* .displayName("My Alert Policy")
* .combiner("OR")
* .conditions(AlertPolicyConditionArgs.builder()
* .displayName("test condition")
* .conditionPrometheusQueryLanguage(AlertPolicyConditionConditionPrometheusQueryLanguageArgs.builder()
* .query("compute_googleapis_com:instance_cpu_usage_time > 0")
* .duration("60s")
* .evaluationInterval("60s")
* .alertRule("AlwaysOn")
* .ruleGroup("a test")
* .build())
* .build())
* .alertStrategy(AlertPolicyAlertStrategyArgs.builder()
* .autoClose("1800s")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* alertPolicy:
* type: gcp:monitoring:AlertPolicy
* name: alert_policy
* properties:
* 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
* ```
*
* ## Import
* AlertPolicy can be imported using any of these accepted formats:
* * `{{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 {{name}}
* ```
* @property alertStrategy Control over how this alert policy's notification channels are notified.
* @property combiner 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`.
* @property conditions 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.
* @property displayName 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.
* @property documentation 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.
* @property enabled Whether or not the policy is enabled. The default is true.
* @property notificationChannels 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]'
* @property project
* @property severity 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"]
* @property userLabels 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.
*/
public data class AlertPolicyArgs(
public val alertStrategy: Output? = null,
public val combiner: Output? = null,
public val conditions: Output>? = null,
public val displayName: Output? = null,
public val documentation: Output? = null,
public val enabled: Output? = null,
public val notificationChannels: Output>? = null,
public val project: Output? = null,
public val severity: Output? = null,
public val userLabels: Output>? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.gcp.monitoring.AlertPolicyArgs =
com.pulumi.gcp.monitoring.AlertPolicyArgs.builder()
.alertStrategy(alertStrategy?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.combiner(combiner?.applyValue({ args0 -> args0 }))
.conditions(
conditions?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.displayName(displayName?.applyValue({ args0 -> args0 }))
.documentation(documentation?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.enabled(enabled?.applyValue({ args0 -> args0 }))
.notificationChannels(notificationChannels?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.project(project?.applyValue({ args0 -> args0 }))
.severity(severity?.applyValue({ args0 -> args0 }))
.userLabels(
userLabels?.applyValue({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
}),
).build()
}
/**
* Builder for [AlertPolicyArgs].
*/
@PulumiTagMarker
public class AlertPolicyArgsBuilder internal constructor() {
private var alertStrategy: Output? = null
private var combiner: Output? = null
private var conditions: Output>? = null
private var displayName: Output? = null
private var documentation: Output? = null
private var enabled: Output? = null
private var notificationChannels: Output>? = null
private var project: Output? = null
private var severity: Output? = null
private var userLabels: Output>? = null
/**
* @param value Control over how this alert policy's notification channels are notified.
*/
@JvmName("ritwfophvonrttif")
public suspend fun alertStrategy(`value`: Output) {
this.alertStrategy = value
}
/**
* @param value 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`.
*/
@JvmName("mhotpmmqpgyitgap")
public suspend fun combiner(`value`: Output) {
this.combiner = value
}
/**
* @param value 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.
*/
@JvmName("snjxvlrihsdgnogq")
public suspend fun conditions(`value`: Output>) {
this.conditions = value
}
@JvmName("nvanfrnveuscbqpv")
public suspend fun conditions(vararg values: Output) {
this.conditions = Output.all(values.asList())
}
/**
* @param values 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.
*/
@JvmName("cetqgslacuowjgeg")
public suspend fun conditions(values: List>) {
this.conditions = Output.all(values)
}
/**
* @param value 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.
*/
@JvmName("gfidybfwvrdlrheu")
public suspend fun displayName(`value`: Output) {
this.displayName = value
}
/**
* @param value 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.
*/
@JvmName("muhoqwphoolvpexm")
public suspend fun documentation(`value`: Output) {
this.documentation = value
}
/**
* @param value Whether or not the policy is enabled. The default is true.
*/
@JvmName("xpeviaghpcojqroj")
public suspend fun enabled(`value`: Output) {
this.enabled = value
}
/**
* @param value 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]'
*/
@JvmName("elkontqanvpgfmpr")
public suspend fun notificationChannels(`value`: Output>) {
this.notificationChannels = value
}
@JvmName("ebcknvmdnfifqmft")
public suspend fun notificationChannels(vararg values: Output) {
this.notificationChannels = Output.all(values.asList())
}
/**
* @param values 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]'
*/
@JvmName("rcshlhaxdxdqptjn")
public suspend fun notificationChannels(values: List>) {
this.notificationChannels = Output.all(values)
}
/**
* @param value
*/
@JvmName("glxcxlqfwnkkubei")
public suspend fun project(`value`: Output) {
this.project = value
}
/**
* @param value 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"]
*/
@JvmName("luapvpletamtphsn")
public suspend fun severity(`value`: Output) {
this.severity = value
}
/**
* @param value 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.
*/
@JvmName("ldxdxweywfgymxix")
public suspend fun userLabels(`value`: Output>) {
this.userLabels = value
}
/**
* @param value Control over how this alert policy's notification channels are notified.
*/
@JvmName("phmkvhxnmjduynnf")
public suspend fun alertStrategy(`value`: AlertPolicyAlertStrategyArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.alertStrategy = mapped
}
/**
* @param argument Control over how this alert policy's notification channels are notified.
*/
@JvmName("xmwylffqvbcucmjd")
public suspend fun alertStrategy(argument: suspend AlertPolicyAlertStrategyArgsBuilder.() -> Unit) {
val toBeMapped = AlertPolicyAlertStrategyArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.alertStrategy = mapped
}
/**
* @param value 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`.
*/
@JvmName("wdcydmfbpcpwplxe")
public suspend fun combiner(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.combiner = mapped
}
/**
* @param value 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.
*/
@JvmName("enxnjhwsvnfqjpog")
public suspend fun conditions(`value`: List?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.conditions = mapped
}
/**
* @param argument 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.
*/
@JvmName("ojcfmgaxmfpsficg")
public suspend fun conditions(argument: List Unit>) {
val toBeMapped = argument.toList().map {
AlertPolicyConditionArgsBuilder().applySuspend {
it()
}.build()
}
val mapped = of(toBeMapped)
this.conditions = mapped
}
/**
* @param argument 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.
*/
@JvmName("yekaceltxugiimpk")
public suspend fun conditions(vararg argument: suspend AlertPolicyConditionArgsBuilder.() -> Unit) {
val toBeMapped = argument.toList().map {
AlertPolicyConditionArgsBuilder().applySuspend {
it()
}.build()
}
val mapped = of(toBeMapped)
this.conditions = mapped
}
/**
* @param argument 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.
*/
@JvmName("obpurfwxvuxedvqm")
public suspend fun conditions(argument: suspend AlertPolicyConditionArgsBuilder.() -> Unit) {
val toBeMapped = listOf(AlertPolicyConditionArgsBuilder().applySuspend { argument() }.build())
val mapped = of(toBeMapped)
this.conditions = mapped
}
/**
* @param values 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.
*/
@JvmName("xhgjwokgiwioktil")
public suspend fun conditions(vararg values: AlertPolicyConditionArgs) {
val toBeMapped = values.toList()
val mapped = toBeMapped.let({ args0 -> of(args0) })
this.conditions = mapped
}
/**
* @param value 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.
*/
@JvmName("ngaoawuyndybdfis")
public suspend fun displayName(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.displayName = mapped
}
/**
* @param value 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.
*/
@JvmName("xnmxumyepilvarcr")
public suspend fun documentation(`value`: AlertPolicyDocumentationArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.documentation = mapped
}
/**
* @param argument 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.
*/
@JvmName("txnhvpsuymohmaoi")
public suspend fun documentation(argument: suspend AlertPolicyDocumentationArgsBuilder.() -> Unit) {
val toBeMapped = AlertPolicyDocumentationArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.documentation = mapped
}
/**
* @param value Whether or not the policy is enabled. The default is true.
*/
@JvmName("mudneojofhpqpoim")
public suspend fun enabled(`value`: Boolean?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.enabled = mapped
}
/**
* @param value 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]'
*/
@JvmName("xqhbvkubyeygqaay")
public suspend fun notificationChannels(`value`: List?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.notificationChannels = mapped
}
/**
* @param values 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]'
*/
@JvmName("dheddfvyvieyhlvv")
public suspend fun notificationChannels(vararg values: String) {
val toBeMapped = values.toList()
val mapped = toBeMapped.let({ args0 -> of(args0) })
this.notificationChannels = mapped
}
/**
* @param value
*/
@JvmName("yvogviqrmdvduuen")
public suspend fun project(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.project = mapped
}
/**
* @param value 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"]
*/
@JvmName("mrfbekgdprqcqfvx")
public suspend fun severity(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.severity = mapped
}
/**
* @param value 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.
*/
@JvmName("lenmixjaofiiljyj")
public suspend fun userLabels(`value`: Map?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.userLabels = mapped
}
/**
* @param values 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.
*/
@JvmName("aixntykyfdrjacyg")
public fun userLabels(vararg values: Pair) {
val toBeMapped = values.toMap()
val mapped = toBeMapped.let({ args0 -> of(args0) })
this.userLabels = mapped
}
internal fun build(): AlertPolicyArgs = AlertPolicyArgs(
alertStrategy = alertStrategy,
combiner = combiner,
conditions = conditions,
displayName = displayName,
documentation = documentation,
enabled = enabled,
notificationChannels = notificationChannels,
project = project,
severity = severity,
userLabels = userLabels,
)
}