Sets the global notification policy for Grafana.
This resource requires Grafana 9.1.0 or later.
resource "grafana_contact_point" "a_contact_point" {
name = "A Contact Point"
email {
addresses = ["one@company.org", "two@company.org"]
message = "{{ len .Alerts.Firing }} firing."
}
}
resource "grafana_mute_timing" "a_mute_timing" {
name = "Some Mute Timing"
intervals {
weekdays = ["monday"]
}
}
resource "grafana_notification_policy" "my_notification_policy" {
group_by = ["..."]
contact_point = grafana_contact_point.a_contact_point.name
group_wait = "45s"
group_interval = "6m"
repeat_interval = "3h"
policy {
matcher {
label = "mylabel"
match = "="
value = "myvalue"
}
matcher {
label = "alertname"
match = "="
value = "CPU Usage"
}
matcher {
label = "Name"
match = "=~"
value = "host.*|host-b.*"
}
contact_point = grafana_contact_point.a_contact_point.name // This can be omitted to inherit from the parent
continue = true
mute_timings = [grafana_mute_timing.a_mute_timing.name]
group_wait = "45s"
group_interval = "6m"
repeat_interval = "3h"
policy {
matcher {
label = "sublabel"
match = "="
value = "subvalue"
}
contact_point = grafana_contact_point.a_contact_point.name // This can also be omitted to inherit from the parent's parent
group_by = ["..."]
}
}
policy {
matcher {
label = "anotherlabel"
match = "=~"
value = "another value.*"
}
contact_point = grafana_contact_point.a_contact_point.name
group_by = ["..."]
}
}
contact_point
(String) The default contact point to route all unmatched notifications to.group_by
(List of String) A list of alert labels to group alerts into notifications by. Use the special label ...
to group alerts by all labels, effectively disabling grouping.disable_provenance
(Boolean) Allow modifying the notification policy from other sources than Terraform or the Grafana API. Defaults to false
.group_interval
(String) Minimum time interval between two notifications for the same group. Default is 5 minutes.group_wait
(String) Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.org_id
(String) The Organization ID. If not set, the Org ID defined in the provider block will be used.policy
(Block List) Routing rules for specific label sets. (see below for nested schema)repeat_interval
(String) Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.id
(String) The ID of this resource.policy
Optional:
contact_point
(String) The contact point to route notifications that match this rule to.continue
(Boolean) Whether to continue matching subsequent rules if an alert matches the current rule. Otherwise, the rule will be 'consumed' by the first policy to match it.group_by
(List of String) A list of alert labels to group alerts into notifications by. Use the special label ...
to group alerts by all labels, effectively disabling grouping. Required for root policy only. If empty, the parent grouping is used.group_interval
(String) Minimum time interval between two notifications for the same group. Default is 5 minutes.group_wait
(String) Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.matcher
(Block Set) Describes which labels this rule should match. When multiple matchers are supplied, an alert must match ALL matchers to be accepted by this policy. When no matchers are supplied, the rule will match all alert instances. (see below for nested schema)mute_timings
(List of String) A list of mute timing names to apply to alerts that match this policy.policy
(Block List) Routing rules for specific label sets. (see below for nested schema)repeat_interval
(String) Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.policy.matcher
Required:
label
(String) The name of the label to match against.match
(String) The operator to apply when matching values of the given label. Allowed operators are =
for equality, !=
for negated equality, =~
for regex equality, and !~
for negated regex equality.value
(String) The label value to match against.policy.policy
Optional:
contact_point
(String) The contact point to route notifications that match this rule to.continue
(Boolean) Whether to continue matching subsequent rules if an alert matches the current rule. Otherwise, the rule will be 'consumed' by the first policy to match it.group_by
(List of String) A list of alert labels to group alerts into notifications by. Use the special label ...
to group alerts by all labels, effectively disabling grouping. Required for root policy only. If empty, the parent grouping is used.group_interval
(String) Minimum time interval between two notifications for the same group. Default is 5 minutes.group_wait
(String) Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.matcher
(Block Set) Describes which labels this rule should match. When multiple matchers are supplied, an alert must match ALL matchers to be accepted by this policy. When no matchers are supplied, the rule will match all alert instances. (see below for nested schema)mute_timings
(List of String) A list of mute timing names to apply to alerts that match this policy.policy
(Block List) Routing rules for specific label sets. (see below for nested schema)repeat_interval
(String) Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.policy.policy.matcher
Required:
label
(String) The name of the label to match against.match
(String) The operator to apply when matching values of the given label. Allowed operators are =
for equality, !=
for negated equality, =~
for regex equality, and !~
for negated regex equality.value
(String) The label value to match against.policy.policy.policy
Optional:
contact_point
(String) The contact point to route notifications that match this rule to.continue
(Boolean) Whether to continue matching subsequent rules if an alert matches the current rule. Otherwise, the rule will be 'consumed' by the first policy to match it.group_by
(List of String) A list of alert labels to group alerts into notifications by. Use the special label ...
to group alerts by all labels, effectively disabling grouping. Required for root policy only. If empty, the parent grouping is used.group_interval
(String) Minimum time interval between two notifications for the same group. Default is 5 minutes.group_wait
(String) Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.matcher
(Block Set) Describes which labels this rule should match. When multiple matchers are supplied, an alert must match ALL matchers to be accepted by this policy. When no matchers are supplied, the rule will match all alert instances. (see below for nested schema)mute_timings
(List of String) A list of mute timing names to apply to alerts that match this policy.policy
(Block List) Routing rules for specific label sets. (see below for nested schema)repeat_interval
(String) Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.policy.policy.policy.matcher
Required:
label
(String) The name of the label to match against.match
(String) The operator to apply when matching values of the given label. Allowed operators are =
for equality, !=
for negated equality, =~
for regex equality, and !~
for negated regex equality.value
(String) The label value to match against.policy.policy.policy.policy
Required:
group_by
(List of String) A list of alert labels to group alerts into notifications by. Use the special label ...
to group alerts by all labels, effectively disabling grouping. Required for root policy only. If empty, the parent grouping is used.Optional:
contact_point
(String) The contact point to route notifications that match this rule to.continue
(Boolean) Whether to continue matching subsequent rules if an alert matches the current rule. Otherwise, the rule will be 'consumed' by the first policy to match it.group_interval
(String) Minimum time interval between two notifications for the same group. Default is 5 minutes.group_wait
(String) Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.matcher
(Block Set) Describes which labels this rule should match. When multiple matchers are supplied, an alert must match ALL matchers to be accepted by this policy. When no matchers are supplied, the rule will match all alert instances. (see below for nested schema)mute_timings
(List of String) A list of mute timing names to apply to alerts that match this policy.repeat_interval
(String) Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.policy.policy.policy.policy.matcher
Required:
label
(String) The name of the label to match against.match
(String) The operator to apply when matching values of the given label. Allowed operators are =
for equality, !=
for negated equality, =~
for regex equality, and !~
for negated regex equality.value
(String) The label value to match against.Import is supported using the following syntax:
terraform import grafana_notification_policy.name "{{ anyString }}"
terraform import grafana_notification_policy.name "{{ orgID }}:{{ anyString }}"