monitoring: системные дашборды + multi-server (file_sd), readme

This commit is contained in:
Ruslan Gilfanov
2026-06-21 19:12:03 +03:00
parent e0adc8997d
commit 29e9079ca4
9 changed files with 24211 additions and 15 deletions

View File

@@ -66,7 +66,8 @@ backend=systemd banaction=ufw
## Мониторинг (`~/monitoring`, stack в репо `stacks/monitoring/`)
- Стек: **Prometheus + Grafana + node-exporter + cAdvisor** (docker compose).
- Prometheus: retention 90d, слушает `127.0.0.1:9090`. Скрейпит node-exporter + cadvisor (job'ы `node`/`cadvisor`, instance `fr1`).
- Grafana: `127.0.0.1:3000`, доступ снаружи через **https://mon.ruzzy.dev** (nginx + Let's Encrypt). Datasource Prometheus провижится автоматически. Пароль admin — в `~/monitoring/docker-compose.yml` на сервере (в репо вынесен в `${GF_ADMIN_PASSWORD}`).
- Grafana: `127.0.0.1:3000`, доступ снаружи через **https://mon.ruzzy.dev** (nginx + Let's Encrypt). Datasource Prometheus (uid `prometheus`) и дашборды (Node Exporter Full, cAdvisor, папка Infra) провижатся автоматически. Пароль admin — в `~/monitoring/docker-compose.yml` на сервере (в репо вынесен в `${GF_ADMIN_PASSWORD}`).
- **Multi-server:** таргеты через file_sd (`prometheus/targets/{node,cadvisor}/*.yml`) — новый сервер = добавить файл + `curl -X POST .../-/reload`. См. `stacks/monitoring/README.md`.
- DNS: `mon.ruzzy.dev` → 161.97.93.252.
- Планируется: VPN-экспортёры (wireguard/openvpn/telemt) + подключение `de1` по туннелю.

View File

@@ -0,0 +1,35 @@
# Monitoring stack (fr1)
Prometheus + Grafana + node-exporter + cAdvisor. Живёт на `fr1` в `~/monitoring`, доступ — https://mon.ruzzy.dev.
## Структура
- `docker-compose.yml` — стек. Grafana пароль через `${GF_ADMIN_PASSWORD}` (`.env`, не в git).
- `prometheus/prometheus.yml` — scrape-конфиг, таргеты через **file_sd**.
- `prometheus/targets/node/*.yml`, `prometheus/targets/cadvisor/*.yml` — таргеты (по файлу на сервер).
- `grafana/provisioning/` — datasource (uid `prometheus`) + дашборды (Node Exporter Full, cAdvisor) как код.
## Запуск
```bash
cd ~/monitoring
echo "GF_ADMIN_PASSWORD=<пароль>" > .env # один раз
docker compose up -d
```
## Добавить новый сервер
На новом сервере поднять `node-exporter` (:9100) и `cadvisor` (:8080), доступные с fr1 (по приватному туннелю).
Затем на fr1 добавить таргеты и перечитать конфиг (без рестарта):
```bash
# ~/monitoring/prometheus/targets/node/<name>.yml
- targets: ['<IP-в-туннеле>:9100']
labels: { instance: <name> }
# ~/monitoring/prometheus/targets/cadvisor/<name>.yml
- targets: ['<IP-в-туннеле>:8080']
labels: { instance: <name> }
curl -s -X POST http://127.0.0.1:9090/-/reload
```
В дашбордах сервер появится в выпадающем списке `instance`.
## Дашборды
Провижатся автоматически (папка **Infra**): Node Exporter Full (1860), cAdvisor (19792). Datasource — Prometheus (uid `prometheus`).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
apiVersion: 1
providers:
- name: infra
orgId: 1
folder: Infra
type: file
disableDeletion: false
updateIntervalSeconds: 30
allowUiUpdates: true
options:
path: /etc/grafana/provisioning/dashboards
foldersFromFilesStructure: false

View File

@@ -1,6 +1,10 @@
apiVersion: 1
deleteDatasources:
- name: Prometheus
orgId: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090

View File

@@ -9,20 +9,12 @@ scrape_configs:
static_configs:
- targets: ['localhost:9090']
# Хосты: новый сервер = добавить файл в targets/node/<name>.yml + reload
- job_name: node
static_configs:
- targets: ['node-exporter:9100']
labels:
instance: fr1
file_sd_configs:
- files: ['/etc/prometheus/targets/node/*.yml']
# Контейнеры
- job_name: cadvisor
static_configs:
- targets: ['cadvisor:8080']
labels:
instance: fr1
# de1 будет добавлен позже (через туннель AmneziaWG):
# - job_name: node-de1
# static_configs:
# - targets: ['10.8.1.X:9100']
# labels: { instance: de1 }
file_sd_configs:
- files: ['/etc/prometheus/targets/cadvisor/*.yml']

View File

@@ -0,0 +1,3 @@
- targets: ['cadvisor:8080']
labels:
instance: fr1

View File

@@ -0,0 +1,3 @@
- targets: ['node-exporter:9100']
labels:
instance: fr1