Add dashboard UID auto-generation and Gitea CI workflow
Some checks failed
terraform-dev / validate (push) Failing after 1m53s
terraform-dev / plan (push) Has been skipped
terraform-dev / apply (push) Has been skipped

This commit is contained in:
Alexandr
2026-03-25 06:41:19 +03:00
parent 345c5786b3
commit 558a23d916
83 changed files with 53372 additions and 1 deletions

View File

@ -0,0 +1,7 @@
locals {
# Define the default contact point name from the contact_points list
default_contact_point_name = try(
element([for cp in var.contact_points : cp.name if try(cp.is_default, false)], 0),
null
)
}

View File

@ -0,0 +1,62 @@
resource "grafana_notification_policy" "default_policy" {
count = local.default_contact_point_name != null ? 1 : 0
org_id = var.org_id
disable_provenance = var.disable_provenance
group_by = var.group_by
contact_point = local.default_contact_point_name
group_wait = var.group_wait
group_interval = var.group_interval
repeat_interval = var.repeat_interval
dynamic "policy" {
for_each = var.notification_policies
content {
contact_point = policy.value.contact_point
continue = policy.value.continue
group_by = policy.value.group_by
group_wait = policy.value.group_wait
group_interval = policy.value.group_interval
repeat_interval = policy.value.repeat_interval
dynamic "matcher" {
for_each = policy.value.matchers
content {
label = matcher.value.label
match = matcher.value.match
value = matcher.value.value
}
}
dynamic "policy" {
for_each = try(policy.value.policies, [])
content {
contact_point = policy.value.contact_point
continue = policy.value.continue
group_by = policy.value.group_by
group_wait = policy.value.group_wait
group_interval = policy.value.group_interval
repeat_interval = policy.value.repeat_interval
dynamic "matcher" {
for_each = policy.value.matchers
content {
label = matcher.value.label
match = matcher.value.match
value = matcher.value.value
}
}
}
}
}
}
# lifecycle {
# prevent_destroy = false
# ignore_changes = all
# }
}

View File

@ -0,0 +1,76 @@
variable "contact_points" {
description = "List of contact points"
type = list(object({
name = string
type = string
is_default = optional(bool, false)
labels = optional(map(string))
settings = map(string)
}))
}
variable "org_id" {
description = "Grafana organization ID"
type = string
}
variable "disable_provenance" {
description = "Controls whether Grafana provisioning is disabled"
type = bool
default = true
}
variable "group_by" {
description = "A list of alert labels to group alerts into notifications"
type = list(string)
default = ["alertname"]
}
variable "group_wait" {
description = "Time to wait to buffer alerts of the same group before sending a notification"
type = string
default = "30s"
}
variable "group_interval" {
description = "Minimum time interval between two notifications for the same group"
type = string
default = "5m"
}
variable "repeat_interval" {
description = "Minimum time interval for re-sending a notification if an alert is still firing"
type = string
default = "4h"
}
variable "notification_policies" {
description = "Routing rules for specific label sets"
type = list(object({
contact_point = string
continue = optional(bool)
group_by = optional(list(string))
group_wait = optional(string)
group_interval = optional(string)
repeat_interval = optional(string)
matchers = list(object({
label = string
match = string # Allowed operators are = for equality, != for negated equality, =~ for regex equality, and !~ for negated regex equality
value = string
}))
policies = optional(list(object({
contact_point = string
continue = optional(bool)
group_by = optional(list(string))
group_wait = optional(string)
group_interval = optional(string)
repeat_interval = optional(string)
matchers = list(object({
label = string
match = string
value = string
}))
})), [])
}))
default = []
}

View File

@ -0,0 +1,7 @@
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
}
}
}