added grafana module
This commit is contained in:
parent
878ecba717
commit
7c9e84971e
38 changed files with 583 additions and 0 deletions
77
grafana/alert-group/alert-group.tf
Normal file
77
grafana/alert-group/alert-group.tf
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
9
grafana/alert-group/providers.tf
Normal file
9
grafana/alert-group/providers.tf
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
grafana = {
|
||||
source = "grafana/grafana"
|
||||
version = "= 3.25.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
grafana/alert-group/variables.tf
Normal file
19
grafana/alert-group/variables.tf
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
variable "group_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "folder_uid" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "datasource_uid" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "rule_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "condition" {
|
||||
type = string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue