terraform-modules/grafana/alert-group/alert-group.tf

77 lines
No EOL
1.8 KiB
HCL

resource "grafana_rule_group" "this" {
name = var.group_name
folder_uid = var.folder_uid
interval_seconds = 60
org_id = 1
disable_provenance = true
rule {
name = "test-alert"
for = "1m"
condition = "C"
no_data_state = "NoData"
exec_err_state = "Error"
is_paused = false
annotations = {
"description" = "Pod `{{ $labels.namespace }}/{{ $labels.pod }}` is crash looping"
"summary" = "Kubernetes pod crash looping (instance {{ $labels.instance }})"
}
data {
ref_id = "A"
query_type = ""
relative_time_range {
from = 600
to = 0
}
datasource_uid = var.datasource_uid
model = jsonencode({
intervalMs = 1000
maxDataPoints = 43200
refId = "A"
expr = "increase(kube_pod_container_status_restarts_total{}[1h]) > 3"
})
}
data {
ref_id = "C"
relative_time_range {
from = 0
to = 0
}
datasource_uid = var.datasource_uid
model = <<EOT
{
"conditions": [
{
"evaluator": {
"params": [0],
"type": "gt"
},
"operator": {
"type": "and"
},
"query": {
"params": ["C"]
},
"reducer": {
"params": [],
"type": "last"
},
"type": "query"
}
],
"datasource": {
"type": "__expr__",
"uid": "__expr__"
},
"expression": "A",
"intervalMs": 1000,
"maxDataPoints": 43200,
"refId": "C",
"type": "threshold"
}
EOT
}
}
}