Стек мониторинга: Prometheus + Alertmanager + Grafana + node_exporter + cAdvisor

Самодостаточный docker compose стек с деплоем через deploy.sh,
bootstrap-установкой с нуля и конфигурацией через .env.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
ShiZa039 2026-07-23 12:54:40 +02:00
commit 74b6f92cb8
15 changed files with 17242 additions and 0 deletions

View file

@ -0,0 +1,43 @@
# Шаблон: deploy.sh рендерит его в rendered/prometheus.yml.
# __ПЛЕЙСХОЛДЕРЫ__ подставляются из .env; строки с префиксом #AUTH#
# включаются только при непустом METRICS_PASSWORD.
global:
scrape_interval: 30s
evaluation_interval: 30s
external_labels:
server: '__SERVER_NAME__'
rule_files:
- /etc/prometheus/rules/*.yml
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
#AUTH# basic_auth:
#AUTH# username: '__METRICS_USER__'
#AUTH# password_file: /etc/prometheus/auth/password
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
#AUTH# basic_auth:
#AUTH# username: '__METRICS_USER__'
#AUTH# password_file: /etc/prometheus/auth/password
# node_exporter работает в host-сети и слушает BIND_IP
- job_name: node
static_configs:
- targets: ['__BIND_IP__:__NODE_EXPORTER_PORT__']
#AUTH# basic_auth:
#AUTH# username: '__METRICS_USER__'
#AUTH# password_file: /etc/prometheus/auth/password
# cAdvisor доступен только по внутренней compose-сети, без auth
- job_name: cadvisor
static_configs:
- targets: ['cadvisor:8080']
# Сюда добавляются удалённые серверы (scrape по tailnet) — см. README

View file

@ -0,0 +1,65 @@
# Статические правила алертов (одинаковые для всех серверов).
# Правила, зависящие от .env (SystemdUnitDown, ContainerDown),
# генерирует deploy.sh в rendered/generated-rules.yml.
groups:
- name: host
rules:
- alert: InstanceDown
expr: up == 0
for: 2m
labels:
severity: critical
annotations:
summary: 'Экспортер {{ $labels.job }} недоступен'
description: 'Таргет {{ $labels.instance }} (job={{ $labels.job }}) недоступен дольше 2 минут.'
- alert: HighCPU
expr: 100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 90
for: 5m
labels:
severity: warning
annotations:
summary: 'CPU > 90%'
description: 'Загрузка CPU на {{ $labels.instance }}: {{ $value | humanize }}% дольше 5 минут.'
- alert: HighRAM
expr: (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 > 90
for: 5m
labels:
severity: warning
annotations:
summary: 'RAM > 90%'
description: 'Использование памяти на {{ $labels.instance }}: {{ $value | humanize }}% дольше 5 минут.'
- alert: DiskFull
expr: >
(1 - node_filesystem_avail_bytes{fstype!~"tmpfs|ramfs|overlay|squashfs|iso9660"}
/ node_filesystem_size_bytes) * 100 > 85
for: 5m
labels:
severity: warning
annotations:
summary: 'Диск {{ $labels.mountpoint }} заполнен более чем на 85%'
description: 'Раздел {{ $labels.mountpoint }} ({{ $labels.device }}) на {{ $labels.instance }}: занято {{ $value | humanize }}%.'
- alert: DiskFull
expr: >
(1 - node_filesystem_avail_bytes{fstype!~"tmpfs|ramfs|overlay|squashfs|iso9660"}
/ node_filesystem_size_bytes) * 100 > 95
for: 1m
labels:
severity: critical
annotations:
summary: 'Диск {{ $labels.mountpoint }} заполнен более чем на 95%'
description: 'Раздел {{ $labels.mountpoint }} ({{ $labels.device }}) на {{ $labels.instance }}: занято {{ $value | humanize }}%. Срочно освободи место.'
- alert: HighTemp
# только сенсоры CPU; если метрик нет вообще — проверь модули coretemp/k10temp (см. README)
expr: max by (instance, chip) (node_hwmon_temp_celsius{chip=~".*coretemp.*|.*k10temp.*"}) > 80
for: 3m
labels:
severity: warning
annotations:
summary: 'Температура CPU > 80°C'
description: 'Сенсор {{ $labels.chip }} на {{ $labels.instance }}: {{ $value | humanize }}°C дольше 3 минут.'