diff --git a/alert_rules_template.json b/alert_rules_template.json index e369c7d..939b3d8 100644 --- a/alert_rules_template.json +++ b/alert_rules_template.json @@ -142,7 +142,8 @@ ], "annotations": { "summary": "🟡 {{ $labels.instance }}: диск / заполнен на {{ $values.\"Занято в /\".Value | printf \"%.1f\" }}% (порог 75%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "af4ok3zmdvny8f", @@ -220,7 +221,8 @@ ], "annotations": { "summary": "🟡 {{ $labels.instance }}: диск /var/log заполнен на {{ $values.\"Занято в /var/log\".Value | printf \"%.1f\" }}% (порог 75%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4ohmap00utcd90", @@ -298,7 +300,8 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: диск / заполнен на {{ $values.\"Занято в /\".Value | printf \"%.1f\" }}% (порог 90%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "af4ok3zmdvny8f90", @@ -376,7 +379,8 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: диск /var/log заполнен на {{ $values.\"Занято в /var/log\".Value | printf \"%.1f\" }}% (порог 90%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spdg2qcge35", @@ -453,7 +457,8 @@ ], "annotations": { "summary": "⚪ {{ $labels.instance }}: CPU загружен на {{ $values.\"Занято CPU\".Value | printf \"%.1f\" }}% (порог 35%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spdg2qcge45", @@ -530,7 +535,8 @@ ], "annotations": { "summary": "🟡 {{ $labels.instance }}: CPU загружен на {{ $values.\"Занято CPU\".Value | printf \"%.1f\" }}% (порог 45%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spdg2qcge8c", @@ -607,7 +613,8 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: CPU загружен на {{ $values.\"Занято CPU\".Value | printf \"%.1f\" }}% (порог 75%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spmgmowe35", @@ -684,7 +691,8 @@ ], "annotations": { "summary": "⚪ {{ $labels.instance }}: RAM занята на {{ $values.\"Занято RAM\".Value | printf \"%.1f\" }}% (порог 35%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spmgmowe45", @@ -761,7 +769,8 @@ ], "annotations": { "summary": "🟡 {{ $labels.instance }}: RAM занята на {{ $values.\"Занято RAM\".Value | printf \"%.1f\" }}% (порог 45%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spmgmowe80e", @@ -838,7 +847,8 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: RAM занята на {{ $values.\"Занято RAM\".Value | printf \"%.1f\" }}% (порог 75%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spdg2qcge8c90", @@ -915,7 +925,8 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: CPU загружен на {{ $values.\"Занято CPU\".Value | printf \"%.1f\" }}% (порог 90%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "ef4spmgmowe80e90", @@ -992,7 +1003,8 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: RAM занята на {{ $values.\"Занято RAM\".Value | printf \"%.1f\" }}% (порог 90%)" - } + }, + "ruleGroup": "[SYSTEM]" }, { "uid": "net_total_35_bond0", @@ -1003,7 +1015,7 @@ "exec_err_state": "Error", "isPaused": false, "folderUID": "", - "ruleGroup": "", + "ruleGroup": "[SYSTEM]", "annotations": { "summary": "⚪ {{ $labels.instance }}: нагрузка на bond0 {{ $values.\"Total\".Value | printf \"%.2f\" }} Гбит/с (порог 35% от 25 Гбит/с)" }, @@ -1083,7 +1095,7 @@ "exec_err_state": "Error", "isPaused": false, "folderUID": "", - "ruleGroup": "", + "ruleGroup": "[SYSTEM]", "annotations": { "summary": "🟡 {{ $labels.instance }}: нагрузка на bond0 {{ $values.\"Total\".Value | printf \"%.2f\" }} Гбит/с (порог 45% от 25 Гбит/с)" }, @@ -1163,7 +1175,7 @@ "exec_err_state": "Error", "isPaused": false, "folderUID": "", - "ruleGroup": "", + "ruleGroup": "[SYSTEM]", "annotations": { "summary": "🔴 {{ $labels.instance }}: нагрузка на bond0 {{ $values.\"Total\".Value | printf \"%.2f\" }} Гбит/с (порог 75% от 25 Гбит/с)" }, @@ -1309,7 +1321,8 @@ "type": "threshold" } } - ] + ], + "ruleGroup": "[Docker]" }, { "uid": "efcxg0oa65gcgd", @@ -1387,11 +1400,216 @@ ], "annotations": { "summary": "🔴 {{ $labels.instance }}: служба angie.service не активна" - } + }, + "ruleGroup": "[SYSTEM]" + }, + { + "uid": "shm_usage_75pct", + "title": "[Docker] SHM Usage 75%", + "condition": "Превышение", + "for": "1m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "isPaused": false, + "folderUID": "", + "ruleGroup": "[Docker]", + "annotations": { + "summary": "🟡 Использование Shared memory контейнером {{ $labels.name }} > 75% > 1 минуты.\nТекущее значение: {{ $values.B.Value | printf \"%.2f\" }} ГБ" + }, + "data": [ + { + "refId": "A", + "relativeTimeRange": { + "from": 300, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "container_shm_usage_bytes / container_shm_size_bytes * 100", + "instant": true, + "intervalMs": 1000, + "legendFormat": "{{name}}", + "maxDataPoints": 43200, + "range": false, + "refId": "A" + } + }, + { + "refId": "B", + "relativeTimeRange": { + "from": 300, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "container_shm_usage_bytes / 1073741824", + "instant": true, + "intervalMs": 1000, + "legendFormat": "{{name}}", + "maxDataPoints": 43200, + "range": false, + "refId": "B" + } + }, + { + "refId": "Превышение", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 75 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "Превышение" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "A", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "Превышение", + "type": "threshold" + } + } + ] + }, + { + "uid": "shm_usage_90pct", + "title": "[Docker] SHM Usage 90%", + "condition": "Превышение", + "for": "1m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "isPaused": false, + "folderUID": "", + "ruleGroup": "[Docker]", + "annotations": { + "summary": "🔴 Использование Shared memory контейнером {{ $labels.name }} > 90% > 1 минуты.\nТекущее значение: {{ $values.B.Value | printf \"%.2f\" }} ГБ\nВнимание! Контейнер может упасть" + }, + "data": [ + { + "refId": "A", + "relativeTimeRange": { + "from": 300, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "container_shm_usage_bytes / container_shm_size_bytes * 100", + "instant": true, + "intervalMs": 1000, + "legendFormat": "{{name}}", + "maxDataPoints": 43200, + "range": false, + "refId": "A" + } + }, + { + "refId": "B", + "relativeTimeRange": { + "from": 300, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "container_shm_usage_bytes / 1073741824", + "instant": true, + "intervalMs": 1000, + "legendFormat": "{{name}}", + "maxDataPoints": 43200, + "range": false, + "refId": "B" + } + }, + { + "refId": "Превышение", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 90 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "Превышение" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "A", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "Превышение", + "type": "threshold" + } + } + ] } ], "contact_point": { "receiver_name": "tg+mail+mattermost PTAF Grafana", - "message_template": "{{ range .Alerts }}{{ if eq .Status \"firing\" }}🔴 Firing{{ else }}✅ Resolved{{ end }}\n{{ if .Annotations.client_domain }}{{ if eq .Annotations.severity \"warning\" }}🟡 {{ .Annotations.client_domain }}{{ if index .Values \"_Reduce\" }} — на WAF {{ index .Values \"_Reduce\" | printf \"%.0f\" }} {{ if .Annotations.value_unit }}{{ .Annotations.value_unit }}{{ end }}{{ end }} {{ if .Annotations.code_field }}{{ .Annotations.code_field }}{{ end }} кодов ответа {{ if .Annotations.field_info }}{{ .Annotations.field_info }}{{ end }}\n{{ if .Annotations.threshold_count }}Пороговое значение {{ .Annotations.threshold_count }}\n{{ end }}{{ else }}{{ if eq .Status \"firing\" }}🔴 {{ .Annotations.client_domain }} — {{ .Annotations.code_field }} ошибок > {{ .Annotations.threshold_value }}% держится > {{ .Annotations.for_duration }}.\nТекущее значение: {{ if index .Values \"Значение\" }}{{ index .Values \"Значение\" | printf \"%.2f\" }}%{{ end }}{{ if index .Values \"_Reduce\" }}{{ index .Values \"_Reduce\" | printf \"%.2f\" }}%{{ end }} {{ if .Annotations.field_info }}{{ .Annotations.field_info }}{{ end }}\n{{ else }}🔴 {{ .Annotations.client_domain }} — {{ .Annotations.code_field }} ошибок < {{ .Annotations.threshold_value }}%.\nТекущее значение: {{ if index .Values \"Значение\" }}{{ index .Values \"Значение\" | printf \"%.2f\" }}%{{ end }}{{ if index .Values \"_Reduce\" }}{{ index .Values \"_Reduce\" | printf \"%.2f\" }}%{{ end }} {{ if .Annotations.field_info }}{{ .Annotations.field_info }}{{ end }}\n{{ end }}{{ end }}{{ else }}{{ if .Annotations.summary }}{{ .Annotations.summary }}\n{{ end }}{{ end }}{{ if eq .Status \"firing\" }}Время сработки алерта: {{ .StartsAt.Format \"2006-01-02 15:04:05 UTC\" }}{{ else }}Время разрешения алерта: {{ .EndsAt.Format \"2006-01-02 15:04:05 UTC\" }}{{ end }}\n{{ if .Annotations.runbook }}\nНеобходимо {{ .Annotations.runbook }}\n{{ end }}{{ end }}" + "message_template": "{{ range .Alerts }}{{ if eq .Status \"firing\" }}🔴 Firing{{ else }}✅ Resolved{{ end }}\n{{ if .Annotations.summary }}{{ .Annotations.summary }}{{ end }}\n\n{{ if index .Values \"Значение\" }}Текущее значение: {{ index .Values \"Значение\" | printf \"%.2f\" }}\n{{ end }}Labels:\n{{ range .Labels.SortedPairs }} • {{ .Name }} = {{ .Value }}\n{{ end }}{{ end }}" } } \ No newline at end of file