Terraform resource: grafana rule group
(Redirected from Grafana rule group)
Jump to navigation
Jump to search
Required[edit]
folder_uid(string) The UID of the folder that the group belongs to.interval_seconds(number) The interval, in seconds, at which all rules in the group are evaluated. If a group contains many rules, the rules are evaluated sequentially.name(string) The name of the rule group.rule
Optional[edit]
datasource_uid(String) The UID of the datasource being queried, or "-100" if this stage is an expression stage.rule.notification_settings
Example[edit]
- Grafana grok example
- Grafana exported example with 1 threshold
- Grafana exported example with 2 thresholds
Official example[edit]
resource "grafana_folder" "rule_folder" { title = "My Alert Rule Folder" } resource "grafana_rule_group" "my_alert_rule" { name = "My Rule Group" folder_uid = grafana_folder.rule_folder.uid interval_seconds = 240 org_id = 1 rule { name = "My Alert Rule 1" for = "2m" condition = "B" no_data_state = "NoData" exec_err_state = "Alerting" annotations = { "a" = "b" "c" = "d" } labels = { "e" = "f" "g" = "h" } is_paused = false data { ref_id = "A" query_type = "" relative_time_range { from = 600 to = 0 } datasource_uid = "PD8C576611E62080A" model = jsonencode({ hide = false intervalMs = 1000 maxDataPoints = 43200 refId = "A" }) } data { ref_id = "B" query_type = "" relative_time_range { from = 0 to = 0 } datasource_uid = "-100" model = <<EOT { "conditions": [ { "evaluator": { "params": [ 3 ], "type": "gt" }, "operator": { "type": "and" }, "query": { "params": [ "A" ] }, "reducer": { "params": [], "type": "last" }, "type": "query" } ], "datasource": { "type": "__expr__", "uid": "-100" }, "hide": false, "intervalMs": 1000, "maxDataPoints": 43200, "refId": "B", "type": "classic_conditions" } EOT } } }
Additional examples[edit]
resource "grafana_rule_group" "rule_group_123456" {
org_id = 1
name = "My_test_evaluation_group"
folder_uid = "123456789"
interval_seconds = 60
rule {
name = "Test Temperature under 0"
condition = "C"
data {
ref_id = "A"
relative_time_range {
from = 604800
to = 0
}
datasource_uid = "1234567890"
model = "{\"alias\":\"Temperature\",\"datasource\":{\"type\":\"influxdb\",\"uid\":\"123456789\"},\"groupBy\":[{\"params\":[\"$__interval\"],\"type\":\"time\"},{\"params\":[\"null\"],\"type\":\"fill\"}],\"hide\":false,\"intervalMs\":1000,\"maxDataPoints\":43200,\"measurement\":\"your-temperature\",\"orderByTime\":\"ASC\",\"policy\":\"default\",\"refId\":\"A\",\"resultFormat\":\"time_series\",\"select\":[[{\"params\":[\"Temperature_degC_0\"],\"type\":\"field\"},{\"params\":[],\"type\":\"mean\"},{\"params\":[\" / 10\"],\"type\":\"math\"}]],\"tags\":[]}"
}
data {
ref_id = "B"
relative_time_range {
from = 0
to = 0
}
datasource_uid = "__expr__"
model = "{\"conditions\":[{\"evaluator\":{\"params\":[],\"type\":\"gt\"},\"operator\":{\"type\":\"and\"},\"query\":{\"params\":[\"B\"]},\"reducer\":{\"params\":[],\"type\":\"last\"},\"type\":\"query\"}],\"datasource\":{\"type\":\"__expr__\",\"uid\":\"__expr__\"},\"expression\":\"A\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"reducer\":\"last\",\"refId\":\"B\",\"type\":\"reduce\"}"
}
data {
ref_id = "C"
relative_time_range {
from = 0
to = 0
}
datasource_uid = "__expr__"
model = "{\"conditions\":[{\"evaluator\":{\"params\":[0],\"type\":\"lt\"},\"operator\":{\"type\":\"and\"},\"query\":{\"params\":[\"C\"]},\"reducer\":{\"params\":[],\"type\":\"last\"},\"type\":\"query\"}],\"datasource\":{\"type\":\"__expr__\",\"uid\":\"__expr__\"},\"expression\":\"B\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"C\",\"type\":\"threshold\"}"
}
no_data_state = "NoData"
exec_err_state = "Error"
is_paused = false
notification_settings {
contact_point = "GoAlert"
group_by = null
mute_timings = null
}
}
}
Related[edit]
See also[edit]
Advertising: