Skip to content

Instantly share code, notes, and snippets.

@ulexxander
Last active July 20, 2023 07:35
Show Gist options
  • Save ulexxander/63d8fdf906b8e12afce657bb247c273f to your computer and use it in GitHub Desktop.
Save ulexxander/63d8fdf906b8e12afce657bb247c273f to your computer and use it in GitHub Desktop.
Prometheus / Grafana / Node Exporter and Docker SD
version: "3.8"
services:
prometheus:
image: prom/prometheus:v2.45.0
command:
- "--web.enable-admin-api"
ports:
- "9090:9090"
volumes:
- prometheus-data:/prometheus/data
- ./prometheus.yml:/prometheus/prometheus.yml
- /var/run/docker.sock:/var/run/docker.sock
user: root
restart: always
labels:
- "prometheus.enable=true"
# 1. Open localhost:3000
# 2. Login as "admin" with password "admin"
# 3. Add Prometheus data source pointing to http://prometheus:9090
# 4. Go to Explore and explore stuff :)
grafana:
image: grafana/grafana:9.5.6
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana
user: root
restart: always
labels:
- "prometheus.enable=true"
# https://grafana.com/docs/grafana-cloud/quickstart/docker-compose-linux/
node-exporter:
image: prom/node-exporter:v1.6.1
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
labels:
- "prometheus.enable=true"
volumes:
prometheus-data:
grafana-data:
global:
scrape_interval: 10s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: docker_sd
docker_sd_configs:
- host: unix:///var/run/docker.sock
filters:
- name: label
values:
- prometheus.enable=true
relabel_configs:
- source_labels:
- __meta_docker_container_id
target_label: docker_container_id
- source_labels:
- __meta_docker_container_name
target_label: docker_container_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment