Skip to content

Configuration reference ​

Everything the stack does is defined by a few files in the repository. This page lists each one with its defaults.

Environment variables ​

Copy .env.example to .env. docker compose loads it automatically. docker stack deploy does not, see the Swarm guide.

VariableDefault in composeValue in .env.exampleUsed by
GF_SECURITY_ADMIN_PASSWORDadminchangemeGrafana admin password, applied when Grafana first creates its database
GF_SERVER_ROOT_URLhttp://localhost:1296http://localhost:1296The public URL Grafana uses in links. Set it to your domain behind a reverse proxy
PROMETHEUS_RETENTION30d30dPassed to --storage.tsdb.retention.time. How long Prometheus keeps data

.env is gitignored. If you add a variable, add it to .env.example and give it a default in docker-compose.yml with the ${VAR:-default} form.

Files ​

txt
docker-compose.yml                       the five services, ports and volumes
.env.example                             template for .env
prometheus.yml                           global intervals, Alertmanager target, scrape jobs
prometheus/rules/node.yml                the node_alerts group, eight rules
alertmanager/alertmanager.yml            routing tree, receivers, inhibit rule
grafana/provisioning/datasources/prometheus.yml    the Prometheus data source
grafana/provisioning/dashboards/dashboard.yml      dashboard file provider
grafana/provisioning/dashboards/json/node-exporter.json   the mounted dashboard
grafana/dashboards/node-exporter.json    second copy of the dashboard, not mounted

Services, images and ports ​

ServiceImageHost portContainer port
grafanagrafana/grafana:13.3.012963000
prometheusprom/prometheus:v3.16.090909090
alertmanagerprom/alertmanager:v0.35.090939093
myserver_node_exporterprom/node-exporter:v1.12.191009100
cadvisorgcr.io/cadvisor/cadvisor:v0.55.180808080

Every service has restart: unless-stopped. Grafana declares depends_on: prometheus, and Prometheus declares depends_on: myserver_node_exporter.

The repository is the source of truth for image tags. Dependabot raises them monthly, so check docker-compose.yml if this table looks behind.

Volumes ​

Three named volumes hold state:

VolumeMounted atHolds
grafana_data/var/lib/grafanaUsers, preferences, dashboards saved in the UI
prometheus_data/prometheusThe time series database
alertmanager_data/alertmanagerSilences and notification state

docker compose down keeps them. docker compose down -v deletes them.

Prometheus ​

Flags set in the compose file:

FlagValue
--config.file/etc/prometheus/prometheus.yml
--storage.tsdb.path/prometheus
--storage.tsdb.retention.time${PROMETHEUS_RETENTION:-30d}
--web.enable-lifecycleon

Settings in prometheus.yml:

SettingValue
global.scrape_interval15s
global.evaluation_interval15s
Alertmanager targetalertmanager:9093
rule_files/etc/prometheus/rules/*.yml
Job nodemyserver_node_exporter:9100, every 5s, label instance
Job cadvisorcadvisor:8080, every 10s
Job prometheuslocalhost:9090, global interval

The node_alerts rule group sets its own interval: 30s, which overrides the global evaluation interval for those rules.

Because the lifecycle API is on, a change to prometheus.yml or a rule file is applied with:

bash
curl -X POST localhost:9090/-/reload

Grafana provisioning ​

The compose file mounts ./grafana/provisioning at /etc/grafana/provisioning.

Data source. One data source named Prometheus, type prometheus, URL http://prometheus:9090, access mode proxy. It is the default and is marked editable: false, so change it in the file and not in the UI.

Dashboards. One file provider named default reads /etc/grafana/provisioning/dashboards/json every 30 seconds and places dashboards in the root folder. disableDeletion is false. Dashboard panels reference the ${datasource} template variable.

Details on the dashboard are in the Node Exporter guide.

Alertmanager ​

Started with --config.file=/etc/alertmanager/alertmanager.yml and --storage.path=/alertmanager. Routing values and receivers are covered in the alerting guide.

Validate a change ​

CI runs three checks on every push and pull request to main. Run the same ones locally before you commit:

bash
docker compose config -q

docker run --rm \
  -v "$PWD/prometheus.yml:/etc/prometheus/prometheus.yml:ro" \
  -v "$PWD/prometheus/rules:/etc/prometheus/rules:ro" \
  --entrypoint promtool prom/prometheus:v3.16.0 \
  check config /etc/prometheus/prometheus.yml

docker run --rm -v "$PWD/alertmanager:/cfg:ro" \
  --entrypoint amtool prom/alertmanager:v0.35.0 \
  check-config /cfg/alertmanager.yml

docker compose config warns that version is obsolete. The warning does not fail the check.

MIT licensed. An independent project, not affiliated with Grafana Labs, the Prometheus project or Docker.