Apply terraform fmt for CI
Some checks failed
terraform-dev / validate (push) Failing after 47s
terraform-dev / plan (push) Has been skipped
terraform-dev / apply (push) Has been skipped

This commit is contained in:
Alexandr
2026-03-25 07:31:02 +03:00
parent ed66d17b70
commit 8f0f9b7f47
25 changed files with 317 additions and 317 deletions

View File

@ -4,8 +4,8 @@ terraform {
source = "grafana/grafana"
version = ">= 4.7.0"
}
vault = {
source = "hashicorp/vault"
vault = {
source = "hashicorp/vault"
}
}
}

View File

@ -5,46 +5,46 @@ locals {
"X-Disable-Provenance" = var.disable_provenance ? "true" : "false"
}
# Contact points configuration
contact_points = [
{
name = "default"
type = "slack"
is_default = true
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_default"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
# Contact points configuration
contact_points = [
{
name = "default"
type = "slack"
is_default = true
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_default"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-critical"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_critical"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-critical"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_critical"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-informational"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_info"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-informational"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_info"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-test"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_test"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
}
]
{
name = "infra-alerts-test"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_test"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
}
]
}

View File

@ -3,8 +3,8 @@ provider "vault" {
}
data "vault_kv_secret_v2" "secret_ext" { # Секреты для подключения к внешним источникам (mm, clickhouse и т.д.)
mount = "app"
name = "groups/monitoring/grafana/dev/ext"
mount = "app"
name = "groups/monitoring/grafana/dev/ext"
}
data "vault_kv_secret_v2" "secret_int" { # Секреты для работы самой графаны

View File

@ -38,36 +38,36 @@ org_id = "2"
# Alert groups configuration
groups = [
{
dashboard_alert_group_name = "System Alerts"
folder_uid = "system"
alert_definitions_path = "alerts/system"
dashboard_path_if_exist = "dashboards/system"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus"]
dashboard_alert_group_name = "System Alerts"
folder_uid = "system"
alert_definitions_path = "alerts/system"
dashboard_path_if_exist = "dashboards/system"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus"]
},
{
dashboard_alert_group_name = "Self monitoring"
folder_uid = "self-monitoring"
alert_definitions_path = "alerts/self-monitoring"
dashboard_path_if_exist = "dashboards/self-monitoring"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus-local-1"]
dashboard_alert_group_name = "Self monitoring"
folder_uid = "self-monitoring"
alert_definitions_path = "alerts/self-monitoring"
dashboard_path_if_exist = "dashboards/self-monitoring"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus-local-1"]
}
]
# Data sources configuration
datasources = [
{
name = "prometheus"
uid = "prometheus"
type = "prometheus"
url = "http://localhost:8481/select/0/prometheus"
access_mode = "proxy"
is_default = true
basic_auth = false
json_data = {
timeInterval = "15s"
name = "prometheus"
uid = "prometheus"
type = "prometheus"
url = "http://localhost:8481/select/0/prometheus"
access_mode = "proxy"
is_default = true
basic_auth = false
json_data = {
timeInterval = "15s"
}
keep_manual_changes = false
prevent_destroy_on_recreate = false
@ -76,79 +76,79 @@ datasources = [
# Notification policies configuration
notification_policies = [
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "disaster"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "critical"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "warning"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "perfomance"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-test"
continue = true
matchers = [
{
label = "status"
match = "="
value = "test"
}
]
}
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "disaster"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "critical"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "warning"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "perfomance"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-test"
continue = true
matchers = [
{
label = "status"
match = "="
value = "test"
}
]
}
]

View File

@ -4,8 +4,8 @@ terraform {
source = "grafana/grafana"
version = ">= 4.7.0"
}
vault = {
source = "hashicorp/vault"
vault = {
source = "hashicorp/vault"
}
}
}

View File

@ -5,46 +5,46 @@ locals {
"X-Disable-Provenance" = var.disable_provenance ? "true" : "false"
}
# Contact points configuration
contact_points = [
{
name = "default"
type = "slack"
is_default = true
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_default"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
# Contact points configuration
contact_points = [
{
name = "default"
type = "slack"
is_default = true
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_default"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-critical"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_critical"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-critical"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_critical"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-informational"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_info"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-informational"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_info"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
},
{
name = "infra-alerts-test"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_test"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
}
]
{
name = "infra-alerts-test"
type = "slack"
is_default = false
settings = {
webhook_url = data.vault_kv_secret_v2.secret_ext.data["mmwebhook_infra_alerts_test"]
template = "../../../modules/grafana_contact_points/template/alerts_message_mm.template"
}
}
]
}

View File

@ -3,8 +3,8 @@ provider "vault" {
}
data "vault_kv_secret_v2" "secret_ext" { # Секреты для подключения к внешним источникам (mm, clickhouse и т.д.)
mount = "app"
name = "groups/monitoring/grafana/dev/ext"
mount = "app"
name = "groups/monitoring/grafana/dev/ext"
}
data "vault_kv_secret_v2" "secret_int" { # Секреты для работы самой графаны

View File

@ -38,36 +38,36 @@ org_id = "35"
# Alert groups configuration
groups = [
{
dashboard_alert_group_name = "System Alerts"
folder_uid = "system"
alert_definitions_path = "alerts/system"
dashboard_path_if_exist = "dashboards/system"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus"]
dashboard_alert_group_name = "System Alerts"
folder_uid = "system"
alert_definitions_path = "alerts/system"
dashboard_path_if_exist = "dashboards/system"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus"]
},
{
dashboard_alert_group_name = "Self monitoring"
folder_uid = "self-monitoring"
alert_definitions_path = "alerts/self-monitoring"
dashboard_path_if_exist = "dashboards/self-monitoring"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus-local-1"]
dashboard_alert_group_name = "Self monitoring"
folder_uid = "self-monitoring"
alert_definitions_path = "alerts/self-monitoring"
dashboard_path_if_exist = "dashboards/self-monitoring"
keep_manual_changes = false
prevent_destroy_on_recreate = false
alerts_on_datasources_uid = ["prometheus-local-1"]
}
]
# Data sources configuration
datasources = [
{
name = "prometheus"
uid = "prometheus"
type = "prometheus"
url = "http://localhost:8481/select/0/prometheus"
access_mode = "proxy"
is_default = true
basic_auth = false
json_data = {
timeInterval = "15s"
name = "prometheus"
uid = "prometheus"
type = "prometheus"
url = "http://localhost:8481/select/0/prometheus"
access_mode = "proxy"
is_default = true
basic_auth = false
json_data = {
timeInterval = "15s"
}
keep_manual_changes = false
prevent_destroy_on_recreate = false
@ -76,79 +76,79 @@ datasources = [
# Notification policies configuration
notification_policies = [
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "disaster"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "critical"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "warning"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "perfomance"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-test"
continue = true
matchers = [
{
label = "status"
match = "="
value = "test"
}
]
}
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "disaster"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-critical"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "critical"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "warning"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-informational"
continue = true
matchers = [
{
label = "severity"
match = "="
value = "perfomance"
},
{
label = "team"
match = "="
value = "infra"
}
]
},
{
contact_point = "infra-alerts-test"
continue = true
matchers = [
{
label = "status"
match = "="
value = "test"
}
]
}
]

View File

@ -18,9 +18,9 @@ resource "grafana_contact_point" "contact_points" {
dynamic "slack" {
for_each = each.value.type == "slack" ? [1] : []
content {
url = each.value.settings["webhook_url"]
title = try(local.contact_point_templates[each.value.name].title, null)
text = local.contact_point_templates[each.value.name].template
url = each.value.settings["webhook_url"]
title = try(local.contact_point_templates[each.value.name].title, null)
text = local.contact_point_templates[each.value.name].template
}
}
}

View File

@ -1,4 +1,4 @@
output "contact_point_ids" {
description = "Mapping of contact point names to their IDs"
value = { for k, v in grafana_contact_point.contact_points : k => v.id }
value = { for k, v in grafana_contact_point.contact_points : k => v.id }
}

View File

@ -1,6 +1,6 @@
variable "contact_points" {
description = "List of contact points for Grafana alerts"
type = list(object({
type = list(object({
name = string
type = string
settings = map(string)

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ locals {
parent_folder_name = length(split("/", group.dashboard_alert_group_name)) > 1 ? join("/", slice(split("/", group.dashboard_alert_group_name), 0, length(split("/", group.dashboard_alert_group_name)) - 1)) : null
folder_title = length(split("/", group.dashboard_alert_group_name)) > 1 ? element(split("/", group.dashboard_alert_group_name), length(split("/", group.dashboard_alert_group_name)) - 1) : group.dashboard_alert_group_name
# Get parent folder UID from parent group's folder_uid
parent_folder_uid = length(split("/", group.dashboard_alert_group_name)) > 1 ? try(local.groups_by_name[join("/", slice(split("/", group.dashboard_alert_group_name), 0, length(split("/", group.dashboard_alert_group_name)) - 1))].folder_uid, null) : null
parent_folder_uid = length(split("/", group.dashboard_alert_group_name)) > 1 ? try(local.groups_by_name[join("/", slice(split("/", group.dashboard_alert_group_name), 0, length(split("/", group.dashboard_alert_group_name)) - 1))].folder_uid, null) : null
}
}

View File

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

View File

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

View File

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

View File

@ -1,11 +1,11 @@
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)
name = string
type = string
is_default = optional(bool, false)
labels = optional(map(string))
settings = map(string)
}))
}
@ -46,31 +46,31 @@ variable "repeat_interval" {
variable "notification_policies" {
description = "Routing rules for specific label sets"
type = list(object({
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({
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({
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({
matchers = list(object({
label = string
match = string
value = string
}))
})), [])
}))
default = []
default = []
}

View File

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

View File

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

View File

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