com.pulumi.gcp.monitoring.kotlin.AlertPolicy.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.monitoring.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyAlertStrategy
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyCondition
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyCreationRecord
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyDocumentation
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyAlertStrategy.Companion.toKotlin as alertPolicyAlertStrategyToKotlin
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyCondition.Companion.toKotlin as alertPolicyConditionToKotlin
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyCreationRecord.Companion.toKotlin as alertPolicyCreationRecordToKotlin
import com.pulumi.gcp.monitoring.kotlin.outputs.AlertPolicyDocumentation.Companion.toKotlin as alertPolicyDocumentationToKotlin
/**
* Builder for [AlertPolicy].
*/
@PulumiTagMarker
public class AlertPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: AlertPolicyArgs = AlertPolicyArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend AlertPolicyArgsBuilder.() -> Unit) {
val builder = AlertPolicyArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): AlertPolicy {
val builtJavaResource = com.pulumi.gcp.monitoring.AlertPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return AlertPolicy(builtJavaResource)
}
}
/**
* 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=[gcp.monitoring.AlertPolicyConditionArgs(
* display_name="test condition",
* condition_threshold=gcp.monitoring.AlertPolicyConditionConditionThresholdArgs(
* filter="metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* duration="60s",
* comparison="COMPARISON_GT",
* aggregations=[gcp.monitoring.AlertPolicyConditionConditionThresholdAggregationArgs(
* 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=[gcp.monitoring.AlertPolicyConditionArgs(
* display_name="test condition",
* condition_threshold=gcp.monitoring.AlertPolicyConditionConditionThresholdArgs(
* filter="metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* duration="60s",
* comparison="COMPARISON_GT",
* aggregations=[gcp.monitoring.AlertPolicyConditionConditionThresholdAggregationArgs(
* 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=[gcp.monitoring.AlertPolicyConditionArgs(
* display_name="test condition",
* condition_threshold=gcp.monitoring.AlertPolicyConditionConditionThresholdArgs(
* filter="metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
* duration="60s",
* forecast_options=gcp.monitoring.AlertPolicyConditionConditionThresholdForecastOptionsArgs(
* forecast_horizon="3600s",
* ),
* comparison="COMPARISON_GT",
* aggregations=[gcp.monitoring.AlertPolicyConditionConditionThresholdAggregationArgs(
* 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=[gcp.monitoring.AlertPolicyConditionArgs(
* display_name="test condition",
* condition_prometheus_query_language=gcp.monitoring.AlertPolicyConditionConditionPrometheusQueryLanguageArgs(
* query="compute_googleapis_com:instance_cpu_usage_time > 0",
* duration="60s",
* evaluation_interval="60s",
* alert_rule="AlwaysOn",
* rule_group="a test",
* ),
* )],
* alert_strategy=gcp.monitoring.AlertPolicyAlertStrategyArgs(
* 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}}
* ```
*/
public class AlertPolicy internal constructor(
override val javaResource: com.pulumi.gcp.monitoring.AlertPolicy,
) : KotlinCustomResource(javaResource, AlertPolicyMapper) {
/**
* Control over how this alert policy's notification channels are notified.
*/
public val alertStrategy: Output?
get() = javaResource.alertStrategy().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> alertPolicyAlertStrategyToKotlin(args0) })
}).orElse(null)
})
/**
* 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`.
*/
public val combiner: Output
get() = javaResource.combiner().applyValue({ args0 -> args0 })
/**
* 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.
*/
public val conditions: Output>
get() = javaResource.conditions().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
alertPolicyConditionToKotlin(args0)
})
})
})
/**
* 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.
*/
public val creationRecords: Output>
get() = javaResource.creationRecords().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> alertPolicyCreationRecordToKotlin(args0) })
})
})
/**
* 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.
*/
public val displayName: Output
get() = javaResource.displayName().applyValue({ args0 -> args0 })
/**
* 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.
*/
public val documentation: Output?
get() = javaResource.documentation().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> alertPolicyDocumentationToKotlin(args0) })
}).orElse(null)
})
/**
* Whether or not the policy is enabled. The default is true.
*/
public val enabled: Output?
get() = javaResource.enabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The unique resource name for this policy.
* Its syntax is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* 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]'
*/
public val notificationChannels: Output>?
get() = javaResource.notificationChannels().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 -> args0 })
}).orElse(null)
})
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* 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"]
*/
public val severity: Output?
get() = javaResource.severity().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* 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 val userLabels: Output
© 2015 - 2024 Weber Informatics LLC | Privacy Policy