One compose file starts Grafana, Prometheus, Alertmanager, Node Exporter and cAdvisor. The data source, a Node Exporter dashboard and eight alert rules are already wired, so the first page you open has graphs on it.
git clone https://github.com/halitsever/grafana-docker-compose.gitcd grafana-docker-composecp .env.example .envdocker compose up -dPanel titles, sizes and thresholds come from the provisioned JSON. The curves are a drawing, not live data.
Set GF_SECURITY_ADMIN_PASSWORD in .env before the first start, then open http://localhost:1296 and sign in as admin. Grafana is on host port 1296 here, not 3000.
The dashboard named Node Exporter is already in the list. Prometheus shows its three scrape jobs at http://localhost:9090/targets and the loaded rules at /alerts.
On Docker Swarm the same file works with docker stack deploy, with a few differences covered in the Swarm guide.
| Service | Port |
|---|---|
| Grafana grafana | 1296 |
| Prometheus prometheus | 9090 |
| Alertmanager alertmanager | 9093 |
| Node Exporter myserver_node_exporter | 9100 |
| cAdvisor cadvisor | 8080 |
Every service publishes its port on the host. Grafana maps 1296 to container port 3000. The rest use the same number on both sides.
Prometheus pulls metrics. It scrapes Node Exporter every 5 seconds, cAdvisor every 10 and itself every 15. Grafana never talks to the exporters. It queries Prometheus at http://prometheus:9090 through a provisioned data source.
Rules in prometheus/rules/node.yml are evaluated every 30 seconds. When one fires, Prometheus sends it to alertmanager:9093, which groups it and hands it to the default or critical receiver.
up == 0100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 90100 - ((node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100) > 90100 - ((node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100) > 95100 - ((node_filesystem_avail_bytes{mountpoint="/",fstype!="tmpfs"} / node_filesystem_size_bytes{mountpoint="/",fstype!="tmpfs"}) * 100) > 85100 - ((node_filesystem_avail_bytes{mountpoint="/",fstype!="tmpfs"} / node_filesystem_size_bytes{mountpoint="/",fstype!="tmpfs"}) * 100) > 95irate(node_network_receive_errs_total[5m]) + irate(node_network_transmit_errs_total[5m]) > 10node_load15 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode) > 2 Alerts labelled severity: critical go to the critical receiver and repeat every hour. Everything else lands on default and repeats every 12 hours.
Both receivers ship empty. The email and Slack webhook blocks are commented out, so no notification leaves the box until you add a receiver.
The repository is configuration only. There is no application code and nothing to build. You get a compose file, a Prometheus config with three scrape jobs, one rule file, an Alertmanager config and Grafana provisioning for the data source and one dashboard.
Retention is 30 days by default and is set with PROMETHEUS_RETENTION. Prometheus runs with --web.enable-lifecycle, so a config change is applied with one HTTP call and no restart. To monitor another server, add its exporter as a second target under the node job.
CI checks every change with docker compose config, promtool check config and amtool check-config. The project is MIT licensed and is not affiliated with Grafana Labs, the Prometheus project or Docker.