monitoring: системные дашборды + multi-server (file_sd), readme
This commit is contained in:
@@ -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` по туннелю.
|
||||
|
||||
|
||||
35
stacks/monitoring/README.md
Normal file
35
stacks/monitoring/README.md
Normal 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`).
|
||||
8610
stacks/monitoring/grafana/provisioning/dashboards/cadvisor.json
Normal file
8610
stacks/monitoring/grafana/provisioning/dashboards/cadvisor.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -1,6 +1,10 @@
|
||||
apiVersion: 1
|
||||
deleteDatasources:
|
||||
- name: Prometheus
|
||||
orgId: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
|
||||
@@ -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']
|
||||
|
||||
3
stacks/monitoring/prometheus/targets/cadvisor/fr1.yml
Normal file
3
stacks/monitoring/prometheus/targets/cadvisor/fr1.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
- targets: ['cadvisor:8080']
|
||||
labels:
|
||||
instance: fr1
|
||||
3
stacks/monitoring/prometheus/targets/node/fr1.yml
Normal file
3
stacks/monitoring/prometheus/targets/node/fr1.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
- targets: ['node-exporter:9100']
|
||||
labels:
|
||||
instance: fr1
|
||||
Reference in New Issue
Block a user