Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for promQL condition type for AlertPolicy #16289

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/9286.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,7 @@ condition to be triggered.`,
"condition_prometheus_query_language": {
Type: schema.TypeList,
Optional: true,
Description: `A Monitoring Query Language query that outputs a boolean stream

A condition type that allows alert policies to be defined using
Description: `A condition type that allows alert policies to be defined using
Prometheus Query Language (PromQL).

The PrometheusQueryLanguageCondition message contains information
Expand Down Expand Up @@ -436,10 +434,7 @@ Some external tools may require this field to be populated correctly
in order to refer to the original Prometheus configuration file.
The rule group name and the alert name are necessary to update the
relevant AlertPolicies in case the definition of the rule group changes
in the future.

This field is optional. If this field is not empty, then it must be a
valid Prometheus label name.`,
in the future. This field is optional.`,
},
},
},
Expand Down
28 changes: 24 additions & 4 deletions website/docs/r/monitoring_alert_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,29 @@ resource "google_monitoring_alert_policy" "alert_policy" {
}
}
```
## Example Usage - Monitoring Alert Policy Promql Condition


```hcl
resource "google_monitoring_alert_policy" "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"
}
}
```

## Argument Reference

Expand Down Expand Up @@ -183,7 +206,6 @@ The following arguments are supported:

* `condition_prometheus_query_language` -
(Optional)
A Monitoring Query Language query that outputs a boolean stream
A condition type that allows alert policies to be defined using
Prometheus Query Language (PromQL).
The PrometheusQueryLanguageCondition message contains information
Expand Down Expand Up @@ -797,9 +819,7 @@ The following arguments are supported:
in order to refer to the original Prometheus configuration file.
The rule group name and the alert name are necessary to update the
relevant AlertPolicies in case the definition of the rule group changes
in the future.
This field is optional. If this field is not empty, then it must be a
valid Prometheus label name.
in the future. This field is optional.

* `alert_rule` -
(Optional)
Expand Down