Initial: Prometheus + Grafana monitoring stack

- Prometheus with 9 scrape targets
- Grafana with Home Server Overview dashboard
- Exporters: node_exporter, cadvisor, postgres_exporter (x3), qbittorrent
- Traefik and Gitea metrics enabled
This commit is contained in:
2026-07-31 15:24:11 +03:00
commit 82f3dae6ab
6 changed files with 377 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
.env
prometheus_data/
grafana_data/
*.log
+140
View File
@@ -0,0 +1,140 @@
name: monitoring
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: always
user: "0:0"
ports:
- "127.0.0.1:9090:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks:
- monitoring
- traefik_proxy
extra_hosts:
- 'host.docker.internal:192.168.1.80'
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: always
user: "0:0"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_SERVER_ROOT_URL=https://grafana.kzbrd.ru
- GF_INSTALL_PLUGINS=grafana-piechart-panel
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.grafana.rule=Host(`grafana.kzbrd.ru`)"
- "traefik.http.routers.grafana.entrypoints=websecure"
- "traefik.http.routers.grafana.tls=true"
- "traefik.http.routers.grafana.tls.certresolver=myresolver"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
- "com.centurylinklabs.watchtower.enable=true"
networks:
- monitoring
- traefik_proxy
node_exporter:
image: prom/node-exporter:latest
container_name: node_exporter
restart: always
command:
- '--path.rootfs=/host'
pid: host
volumes:
- /:/host:ro,rslave
networks:
- monitoring
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
restart: always
privileged: true
command:
- '--port=8081'
devices:
- /dev/kmsg
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
networks:
- monitoring
postgres_exporter_pgvector:
image: prometheuscommunity/postgres-exporter:latest
container_name: postgres_exporter_pgvector
restart: always
environment:
- DATA_SOURCE_NAME=postgresql://postgres:${PGVECTOR_PASSWORD}@host.docker.internal:5432/postgres?sslmode=disable
networks:
- monitoring
extra_hosts:
- 'host.docker.internal:192.168.1.80'
postgres_exporter_langfuse:
image: prometheuscommunity/postgres-exporter:latest
container_name: postgres_exporter_langfuse
restart: always
command:
- '--web.listen-address=:9188'
environment:
- DATA_SOURCE_NAME=postgresql://postgres:${LANGFUSE_DB_PASSWORD}@langfuse-postgres-1:5432/langfuse?sslmode=disable
networks:
- monitoring
- langfuse_default
postgres_exporter_mcpjungle:
image: prometheuscommunity/postgres-exporter:latest
container_name: postgres_exporter_mcpjungle
restart: always
command:
- '--web.listen-address=:9189'
environment:
- DATA_SOURCE_NAME=postgresql://mcpjungle:${MCPJUNGLE_DB_PASSWORD}@mcpjungle-db:5432/mcpjungle?sslmode=disable
networks:
- monitoring
- mcpjungle_internal
qbittorrent_exporter:
image: ghcr.io/esanchezm/prometheus-qbittorrent-exporter:latest
container_name: qbittorrent_exporter
restart: always
environment:
- QBITTORRENT_HOST=qbittorrent
- QBITTORRENT_PORT=8080
- QBITTORRENT_API_KEY=${QBIT_PASSWORD}
networks:
- monitoring
- traefik_proxy
networks:
monitoring:
driver: bridge
traefik_proxy:
external: true
langfuse_default:
external: true
mcpjungle_internal:
external: true
volumes:
prometheus_data:
grafana_data:
@@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards
@@ -0,0 +1,173 @@
{
"annotations": {
"list": []
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"id": null,
"links": [],
"panels": [
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "palette-classic"},
"custom": {"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "auto", "spanNulls": false, "stacking": {"group": "A", "mode": "none"}, "thresholdsStyle": {"mode": "off"}},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}]},
"unit": "percent"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
"id": 1,
"options": {"legend": {"calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "100 - (avg by (instance) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)", "legendFormat": "{{instance}}", "refId": "A"}
],
"title": "CPU Usage",
"type": "timeseries"
},
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "palette-classic"},
"custom": {"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "auto", "spanNulls": false, "stacking": {"group": "A", "mode": "none"}, "thresholdsStyle": {"mode": "off"}},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}]},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
"id": 2,
"options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes", "legendFormat": "Used", "refId": "A"},
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "node_memory_MemTotal_bytes", "legendFormat": "Total", "refId": "B"}
],
"title": "Memory Usage",
"type": "timeseries"
},
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "thresholds"},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}, {"color": "yellow", "value": 50}, {"color": "red", "value": 80}]},
"unit": "percent"
},
"overrides": []
},
"gridPos": {"h": 5, "w": 6, "x": 0, "y": 8},
"id": 3,
"options": {"orientation": "auto", "reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}, "showThresholdLabels": false, "showThresholdMarkers": true},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "100 - ((node_filesystem_avail_bytes{mountpoint=\"/\"} / node_filesystem_size_bytes{mountpoint=\"/\"}) * 100)", "legendFormat": "Root", "refId": "A"}
],
"title": "Disk Usage /",
"type": "gauge"
},
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "palette-classic"},
"custom": {"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "auto", "spanNulls": false, "stacking": {"group": "A", "mode": "none"}, "thresholdsStyle": {"mode": "off"}},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}]},
"unit": "Bps"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 13},
"id": 4,
"options": {"legend": {"calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "rate(node_network_receive_bytes_total{device!=\"lo\"}[5m])", "legendFormat": "{{device}} RX", "refId": "A"},
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "-rate(node_network_transmit_bytes_total{device!=\"lo\"}[5m])", "legendFormat": "{{device}} TX", "refId": "B"}
],
"title": "Network Traffic",
"type": "timeseries"
},
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "palette-classic"},
"custom": {"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "auto", "spanNulls": false, "stacking": {"group": "A", "mode": "none"}, "thresholdsStyle": {"mode": "off"}},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}]},
"unit": "short"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 13},
"id": 5,
"options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "count(count by (name) (container_last_seen{name=~\".+\"}))", "legendFormat": "Running containers", "refId": "A"}
],
"title": "Docker Containers",
"type": "timeseries"
},
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "palette-classic"},
"custom": {"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "auto", "spanNulls": false, "stacking": {"group": "A", "mode": "none"}, "thresholdsStyle": {"mode": "off"}},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}]},
"unit": "short"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 21},
"id": 6,
"options": {"legend": {"calcs": ["mean"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "rate(traefik_service_requests_total{service=~\"grafana.*|gitea.*|langfuse.*|pingvin.*\"}[5m])", "legendFormat": "{{service}}", "refId": "A"}
],
"title": "Traefik HTTP Requests (by service)",
"type": "timeseries"
},
{
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
"fieldConfig": {
"defaults": {
"color": {"mode": "palette-classic"},
"custom": {"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "auto", "spanNulls": false, "stacking": {"group": "A", "mode": "none"}, "thresholdsStyle": {"mode": "off"}},
"mappings": [],
"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}]},
"unit": "short"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 21},
"id": 7,
"options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
"targets": [
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "gitea_repositories", "legendFormat": "Repositories", "refId": "A"},
{"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "expr": "gitea_issues", "legendFormat": "Issues", "refId": "B"}
],
"title": "Gitea Stats",
"type": "timeseries"
}
],
"refresh": "30s",
"schemaVersion": 39,
"tags": ["overview"],
"templating": {
"list": []
},
"time": {"from": "now-1h", "to": "now"},
"timepicker": {},
"timezone": "browser",
"title": "Home Server Overview",
"uid": "home-overview",
"version": 1
}
@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
+40
View File
@@ -0,0 +1,40 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: traefik
static_configs:
- targets: ['traefik:8080']
- job_name: gitea
static_configs:
- targets: ['gitea:3000']
- job_name: node
static_configs:
- targets: ['node_exporter:9100']
- job_name: cadvisor
static_configs:
- targets: ['cadvisor:8081']
- job_name: postgres_pgvector
static_configs:
- targets: ['postgres_exporter_pgvector:9187']
- job_name: postgres_langfuse
static_configs:
- targets: ['postgres_exporter_langfuse:9188']
- job_name: postgres_mcpjungle
static_configs:
- targets: ['postgres_exporter_mcpjungle:9189']
- job_name: qbittorrent
static_configs:
- targets: ['qbittorrent_exporter:8000']