Skip to content

Commit

Permalink
Add example for promQL condition type for AlertPolicy (#9286) (#16289)
Browse files Browse the repository at this point in the history
[upstream:2ea077768c3e3b9f7b139bbfb4ea52cade8db018]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 17, 2023
1 parent 8404240 commit 3488b9e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
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

0 comments on commit 3488b9e

Please sign in to comment.