Skip to content

Commit c146ee5

Browse files
authored
docs: Clarify alerts override (#3)
1 parent 74fb5f8 commit c146ee5

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,42 @@ module "cert_manager_rules" {
3838

3939
## Overriding definitions of Prometheus Alerting file
4040

41-
TODO
41+
The alerts defined as [Prometheus Alerting rules] can be overridden without changing the input file.
42+
If your Prometheus Alerting rules YAML contains an alert `alert: TooManyWriteErrors`, you can override it like this:
43+
44+
```hcl
45+
module "cert_manager_rules" {
46+
source = "github.com/mkilchhofer/terraform-grafana-prometheus-alerts"
47+
48+
prometheus_alerts_file_path = file("/path/to/alerts/cert-manager.yaml")
49+
folder_uid = grafana_folder.test.uid
50+
datasource_uid = grafana_data_source.prometheus.uid
51+
52+
# Overrides per alert
53+
overrides = {
54+
"TooManyWriteErrors" = {
55+
alert_threshold = 1
56+
is_paused = true
57+
58+
labels = {
59+
mycustomlabel = "foobar" # Add an extra label
60+
severity = "notify" # Override severity
61+
}
62+
}
63+
}
64+
}
65+
```
66+
67+
Every alert supports the following overrides:
68+
69+
| Override parameter | Type | Description |
70+
|--------------------|---------------|-------------|
71+
| `alert_threshold` | `number` | Threshold of the Grafana alert. Defaults to `0` |
72+
| `exec_err_state` | `string` | Describes what state to enter when the rule's query is invalid and the rule cannot be executed. Options are `OK`, `Error`, `KeepLast`, and `Alerting`. Defaults to `Error`. |
73+
| `is_paused` | `bool` | Sets whether the alert should be paused or not. Defaults to `false`. |
74+
| `no_data_state` | `string` | Describes what state to enter when the rule's query returns No Data. Options are `OK`, `NoData`, `KeepLast`, and `Alerting`. Defaults to `OK`. |
75+
| `labels` | `map(string)` | Extra labels to add. It is also possible to override already defined labels like `severity`. |
76+
4277

4378
## TF module documentation
4479

grafana_alert.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ resource "grafana_rule_group" "this" {
2727
annotations = {for k, v in rule.value.annotations : k => replace(v, "$value", "$values.QUERY_RESULT.Value")}
2828
labels = merge(rule.value.labels, try(var.overrides[rule.value.alert].labels, {}))
2929

30-
exec_err_state = try(var.overrides[rule.value.alert].exec_err_state, null)
30+
exec_err_state = try(var.overrides[rule.value.alert].exec_err_state, "Error")
3131
is_paused = try(var.overrides[rule.value.alert].is_paused, null)
32-
no_data_state = try(var.overrides[rule.value.alert].no_data_state, null)
32+
no_data_state = try(var.overrides[rule.value.alert].no_data_state, "OK")
3333

3434
data {
3535
ref_id = "QUERY"

0 commit comments

Comments
 (0)