diff --git a/README.md b/README.md index 8b19620..7a357b6 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ TODO | disable\_provenance | Allow modifying the rule group from other sources than Terraform or the Grafana API. | `bool` | `false` | no | | folder\_uid | The UID of the Grafana folder that the alerts belongs to. | `string` | n/a | yes | | org\_id | The Organization ID of of the Grafana Alerting rule groups. (Only supported with basic auth, API keys are already org-scoped) | `string` | `null` | no | -| overrides | Overrides per Alert rule |
map(object({| `{}` | no | +| overrides | Overrides per Alert rule |
alert_threshold = optional(number)
exec_err_state = optional(string)
is_paused = optional(bool)
no_data_state = optional(string)
}))
map(object({| `{}` | no | | prometheus\_alerts\_file\_path | Path to the Prometheus Alerting rules file | `string` | n/a | yes | ### Outputs diff --git a/grafana_alert.tf b/grafana_alert.tf index ab597d4..2e138b7 100644 --- a/grafana_alert.tf +++ b/grafana_alert.tf @@ -25,7 +25,7 @@ resource "grafana_rule_group" "this" { condition = "ALERTCONDITION" annotations = {for k, v in rule.value.annotations : k => replace(v, "$value", "$values.QUERY_RESULT.Value")} - labels = rule.value.labels + labels = merge(rule.value.labels, try(var.overrides[rule.value.alert].labels, {})) exec_err_state = try(var.overrides[rule.value.alert].exec_err_state, null) is_paused = try(var.overrides[rule.value.alert].is_paused, null) diff --git a/test/test.tf b/test/test.tf index 9279d49..e9bf03a 100644 --- a/test/test.tf +++ b/test/test.tf @@ -34,6 +34,10 @@ module "test_vmagent" { overrides = { "TooManyWriteErrors" = { alert_threshold = 1 + + labels = { + mycustomlabel = "foobar" + } } } } diff --git a/variables.tf b/variables.tf index 44f51ce..b7e35fb 100644 --- a/variables.tf +++ b/variables.tf @@ -20,6 +20,7 @@ variable "overrides" { exec_err_state = optional(string) is_paused = optional(bool) no_data_state = optional(string) + labels = optional(map(string)) })) default = {} }
alert_threshold = optional(number)
exec_err_state = optional(string)
is_paused = optional(bool)
no_data_state = optional(string)
labels = optional(map(string))
}))