Setting up Grafana dashboards and alerting for a homelab
Deploy Grafana in Docker with provisioned Prometheus datasources, official dashboards (1860, 7362, 11835), Nginx Proxy Manager WebSockets, and Telegram alerts.
Collecting metrics in Prometheus only helps if you can read them quickly and get notified when something breaks. This post walks through deploying Grafana with Docker Compose, provisioning the Prometheus datasource as code, importing proven community dashboards, and routing Unified Alerting notifications to Telegram and Discord.
Tested with Grafana
11.2.0, Prometheusv2.54.1, and Nginx Proxy Manager on a homelab Docker host.
Why dashboards and alerting belong together
Once Node Exporter and the MariaDB and Redis exporters are feeding Prometheus, you have all the raw time-series data you need. Typing PromQL into the Prometheus Graph tab works for ad-hoc debugging, but it’s a poor way to spot trends across host hardware and databases—and nobody stares at a browser tab 24 hours a day.
Pairing visual dashboards with threshold-based alerting closes that loop. Grafana handles both in one container:
flowchart TD
subgraph StorageTier["Metrics Storage"]
PROM["Prometheus TSDB (:9090)"]
end
subgraph VisualizationTier["Grafana"]
DS["Prometheus Datasource (Provisioned)"]
DASH["Dashboards (Host, MariaDB, Redis)"]
ENGINE["Unified Alerting (1m eval)"]
end
subgraph IngressTier["External Access"]
NPM["Nginx Proxy Manager (grafana.namju.kim)"]
USER["Browser"]
end
subgraph NotificationTier["Contact Points"]
TG["Telegram Bot API"]
DC["Discord Webhook"]
end
USER -->|"HTTPS"| NPM
NPM -->|"Reverse proxy (SSL/WS)"| DASH
PROM -->|"HTTP API"| DS
DS --> DASH
DS --> ENGINE
ENGINE -->|"Threshold breach"| TG
ENGINE -->|"Fan-out alert"| DC
Grafana queries Prometheus over the internal Docker network, renders interactive panels, and evaluates alert rules on a schedule before dispatching notifications to Telegram and Discord.
When shouldn’t you use Grafana Unified Alerting? If you already run a dedicated Alertmanager cluster with complex inhibition rules and PagerDuty routing, keep your alert logic in Alertmanager. For a single-node homelab, Grafana’s built-in alerting eliminates an extra container and config format.
Provisioning the Prometheus datasource as code
Clicking through the Grafana UI to add a datasource works once, but if you rebuild the container or migrate to a new host, you end up repeating manual steps. Grafana’s file-based provisioning registers datasources automatically on startup.
Create grafana/provisioning/datasources/prometheus.yml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# grafana/provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
# Resolve Prometheus by container/service name on the shared bridge network
url: http://monitoring-prometheus:9090
isDefault: true
editable: false
jsonData:
timeInterval: 15s
httpMethod: POST
url: http://monitoring-prometheus:9090: Talks directly to Prometheus over Docker DNS without exposing or depending on a host port.editable: false: Locks the datasource in the UI so you can’t accidentally break or delete it while browsing settings.
Grafana runs as UID/GID
472:472inside the container. If you bind-mount a host directory instead of a named Docker volume, Grafana will fail to start withPermission deniedunless you runchown -R 472:472 ./grafana/datafirst. Using a named volume (grafana_data) avoids this headache.
Three community dashboards worth importing
Building panels from scratch takes hours. The Grafana community maintains battle-tested dashboards that you can import by ID in under a minute:
| Dashboard | Grafana.com ID | Key metrics covered |
|---|---|---|
| Node Exporter Full | 1860 | Per-core CPU load, RAM and swap usage, uptime, disk space by mount, network bandwidth |
| MySQL / MariaDB Overview | 7362 | QPS, active threads (Threads Connected), slow query trends, InnoDB buffer pool hit ratio |
| Redis Exporter Dashboard | 11835 | used_memory, mem_fragmentation_ratio, cache hit rate, commands/sec, client connections |
Together, these three dashboards cover the entire homelab stack from bare-metal hardware up through MariaDB and Redis.
Docker Compose and environment setup
Add Grafana and its provisioning directory to the existing ~/homelab-monitoring layout:
1
2
3
4
5
6
7
8
9
~/homelab-monitoring/
├── .env
├── docker-compose.yml
├── grafana/
│ └── provisioning/
│ └── datasources/
│ └── prometheus.yml
└── prometheus/
└── prometheus.yml
Environment file (.env)
Store the admin credentials, public URL, and alert webhook tokens in .env (kept out of Git):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# .env
TZ=Asia/Seoul
PROMETHEUS_PORT=9090
GRAFANA_PORT=3000
# Grafana admin account and domain
GF_SECURITY_ADMIN_USER=admin
GF_SECURITY_ADMIN_PASSWORD=replace_with_strong_grafana_password
GF_SERVER_DOMAIN=grafana.namju.kim
GF_SERVER_ROOT_URL=https://grafana.namju.kim/
# Alerting tokens (masked placeholders)
TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz_SAMPLE
TELEGRAM_CHAT_ID=-1001234567890
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/1234567890/sample_token_abcdefg
Complete docker-compose.yml
Notice GF_USERS_ALLOW_SIGN_UP=false to block public registration, and GF_SERVER_ROOT_URL so alert links point to the real HTTPS domain instead of localhost:3000:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# docker-compose.yml
services:
prometheus:
image: prom/prometheus:v2.54.1
container_name: monitoring-prometheus
restart: unless-stopped
user: "65534:65534"
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention.time=30d"
- "--storage.tsdb.retention.size=20GB"
- "--storage.tsdb.wal-compression"
- "--web.enable-lifecycle"
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks:
- monitoring-net
grafana:
image: grafana/grafana:11.2.0
container_name: monitoring-grafana
restart: unless-stopped
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
- TZ=${TZ:-Asia/Seoul}
- GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
- GF_SERVER_DOMAIN=${GF_SERVER_DOMAIN}
- GF_SERVER_ROOT_URL=${GF_SERVER_ROOT_URL}
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-piechart-panel
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
networks:
- monitoring-net
depends_on:
- prometheus
volumes:
prometheus_data:
name: homelab_prometheus_data
grafana_data:
name: homelab_grafana_data
networks:
monitoring-net:
name: homelab_monitoring_net
driver: bridge
Launch the Grafana container:
1
docker compose up -d grafana
Reverse proxy and WebSocket setup in Nginx Proxy Manager
Expose Grafana at https://grafana.namju.kim through Nginx Proxy Manager:
- In NPM, open Hosts > Proxy Hosts > Add Proxy Host.
- Set the Details tab:
- Domain Names:
grafana.namju.kim - Scheme:
http - Forward Hostname / IP: your host IP or Docker gateway IP
- Forward Port:
3000 - Block Common Exploits: ON
- Websockets Support: ON
- Domain Names:
- Under the SSL tab, select your wildcard SSL certificate and turn on Force SSL, HTTP/2 Support, and HSTS Enabled.
Don’t skip Websockets Support. Grafana Live relies on WebSockets for real-time panel updates. If you leave
Websockets Supportdisabled in NPM, browser devtools will fill up withWebSocket connection failederrors and live streaming panels will stall.
Configuring Telegram and Discord alerts
With Grafana running, set up Unified Alerting so real problems reach your phone without flooding you with noise.
Register Contact Points
In the Grafana sidebar, go to Alerting > Contact points > Add contact point:
- Telegram:
- Name:
Homelab Telegram Alerts - Integration:
Telegram - BOT API Token: your
${TELEGRAM_BOT_TOKEN} - Chat ID: your
${TELEGRAM_CHAT_ID} - Click Test to confirm the test message arrives in your Telegram chat.
- Name:
- Discord:
- Name:
Homelab Discord Alerts - Integration:
Discord - Webhook URL: your
${DISCORD_WEBHOOK_URL} - Click Test to confirm the webhook posts to your Discord channel.
- Name:
Define high-signal Alert Rules
Go to Alerting > Alert rules > New alert rule and start with two baseline rules that prevent actual outages:
Rule 1: Sustained high CPU (HostHighCpuUsage, Warning)
- PromQL:
100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) - Condition:
IS ABOVE 90 - Evaluation: Every
1m, Pending period:5m - Why 5 minutes? Short Docker builds or Gradle compilations routinely spike CPU for 30–60 seconds. Requiring a 5-minute pending window filters out harmless build spikes and keeps alert fatigue down.
Rule 2: Low root disk space (HostDiskSpaceCritical, Critical)
- PromQL:
(node_filesystem_avail_bytes{mountpoint="/rootfs"} * 100) / node_filesystem_size_bytes{mountpoint="/rootfs"} - Condition:
IS BELOW 10 - Evaluation: Every
1m, Pending period:1m - Why 1 minute? Once free disk space drops under 10%, you want immediate notice before container logs or database writes lock up the Docker daemon.
Importing the dashboards and final checklist
Log in to https://grafana.namju.kim with your admin account:
- Go to Dashboards > New > Import.
- Enter
1860under Import via grafana.com and click Load. - Pick the provisioned
Prometheusdatasource from the dropdown and click Import. - Repeat for
7362(MariaDB) and11835(Redis).
Before calling the setup done, run through this quick checklist:
- Provisioned datasource: Confirm
Prometheusappears automatically witheditable: falseafter a container recreate. - Public sign-up disabled: Verify
GF_USERS_ALLOW_SIGN_UP=falseis active before exposing the domain. - WebSockets enabled: Check the browser console on a live dashboard to confirm zero WebSocket errors.
- Tested alert delivery: Send a test notification to both Telegram and Discord, and tune pending periods so routine builds don’t page you.
With time-series metrics and alerting covered, the other half of homelab observability is centralized log search—which I set up using a lightweight Docker ELK stack.