Docker Compose for Grafana + Prometheus

Monitoring stack with Grafana dashboards and Prometheus metrics collection.

grafana prometheus monitoring observability
compose.yaml
services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - target: 3000
        mode: ingress
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost:3000/api/health
      interval: 30s
      timeout: 5s
      retries: 3
    depends_on:
      - prometheus
    deploy:
      resources:
        reservations:
          cpus: "0.5"
          memory: 256M
    restart: unless-stopped
  prometheus:
    image: prom/prometheus:latest
    ports:
      - target: 9090
        mode: host
    healthcheck:
      test:
        - CMD
        - wget
        - --spider
        - -q
        - http://localhost:9090/-/healthy
      interval: 30s
      timeout: 5s
      retries: 3
    deploy:
      resources:
        reservations:
          cpus: "0.5"
          memory: 256M
    restart: unless-stopped

Services

  • grafana grafana/grafana:latest
  • prometheus prom/prometheus:latest

Deploy

$ npx defang@latest compose up

Learn more about Defang