|
| 1 | +## |
| 2 | +## Grafana LGTM Observability Stack for Dgraph |
| 3 | +## |
| 4 | +## Components: |
| 5 | +## - Prometheus (metrics collection) |
| 6 | +## - Grafana Tempo (distributed tracing) |
| 7 | +## - Grafana Loki (log aggregation) |
| 8 | +## - OpenTelemetry Collector (trace pipeline) |
| 9 | +## - Promtail (log collection via Docker API) |
| 10 | +## - Grafana (visualization & dashboards) |
| 11 | +## |
| 12 | +## Usage: |
| 13 | +## |
| 14 | +## Monitoring stack only (external Dgraph cluster): |
| 15 | +## 1. Edit prometheus/targets/dgraph.json with your Alpha/Zero addresses |
| 16 | +## 2. Configure your Dgraph cluster with: --trace "jaeger=<collector-host>:4318; ..." |
| 17 | +## 3. docker compose up -d |
| 18 | +## |
| 19 | +## With a local Dgraph cluster: |
| 20 | +## docker compose -f docker-compose.yml -f docker-compose.dgraph.yml up -d |
| 21 | +## |
| 22 | +## Open Grafana at http://localhost:3000 (admin/admin) |
| 23 | +## |
| 24 | + |
| 25 | +services: |
| 26 | + # ────────────────────────────────────────────── |
| 27 | + # OpenTelemetry Collector |
| 28 | + # Receives OTLP traces from Dgraph and forwards |
| 29 | + # them to Tempo. |
| 30 | + # ────────────────────────────────────────────── |
| 31 | + otel-collector: |
| 32 | + image: otel/opentelemetry-collector-contrib:latest |
| 33 | + container_name: otel-collector |
| 34 | + restart: unless-stopped |
| 35 | + command: ["--config=/etc/otelcol/config.yaml"] |
| 36 | + volumes: |
| 37 | + - ./otel-collector/config.yaml:/etc/otelcol/config.yaml:ro |
| 38 | + # Uncomment ports below if you need host access for debugging. |
| 39 | + # In Mode 2, the collector is reachable via the Docker network. |
| 40 | + # ports: |
| 41 | + # - "4317:4317" # OTLP gRPC |
| 42 | + # - "4318:4318" # OTLP HTTP |
| 43 | + # - "8888:8888" # Collector metrics |
| 44 | + depends_on: |
| 45 | + - tempo |
| 46 | + |
| 47 | + # ────────────────────────────────────────────── |
| 48 | + # Prometheus — Metrics |
| 49 | + # Scrapes /metrics from Dgraph Alpha and Zero. |
| 50 | + # ────────────────────────────────────────────── |
| 51 | + prometheus: |
| 52 | + image: prom/prometheus:latest |
| 53 | + container_name: prometheus |
| 54 | + restart: unless-stopped |
| 55 | + command: |
| 56 | + - "--config.file=/etc/prometheus/prometheus.yml" |
| 57 | + - "--storage.tsdb.path=/prometheus" |
| 58 | + - "--storage.tsdb.retention.time=30d" |
| 59 | + - "--web.enable-lifecycle" |
| 60 | + - "--web.enable-remote-write-receiver" |
| 61 | + - "--enable-feature=exemplar-storage" |
| 62 | + volumes: |
| 63 | + - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro |
| 64 | + - ./prometheus/targets:/etc/prometheus/targets:ro |
| 65 | + - prometheus-data:/prometheus |
| 66 | + ports: |
| 67 | + - "9090:9090" |
| 68 | + |
| 69 | + # ────────────────────────────────────────────── |
| 70 | + # Grafana Tempo — Distributed Tracing |
| 71 | + # Receives OTLP traces via the OTel Collector. |
| 72 | + # ────────────────────────────────────────────── |
| 73 | + tempo: |
| 74 | + image: grafana/tempo:2.6.1 |
| 75 | + container_name: tempo |
| 76 | + restart: unless-stopped |
| 77 | + command: ["-config.file=/etc/tempo/tempo.yaml"] |
| 78 | + volumes: |
| 79 | + - ./tempo/tempo.yaml:/etc/tempo/tempo.yaml:ro |
| 80 | + - tempo-data:/var/tempo |
| 81 | + ports: |
| 82 | + - "3200:3200" # Tempo HTTP API |
| 83 | + - "4320:4317" # OTLP gRPC (mapped to avoid conflict with collector) |
| 84 | + |
| 85 | + # ────────────────────────────────────────────── |
| 86 | + # Promtail — Log Collection |
| 87 | + # Collects Docker container logs via Docker API |
| 88 | + # and ships them to Loki. |
| 89 | + # ────────────────────────────────────────────── |
| 90 | + promtail: |
| 91 | + image: grafana/promtail:latest |
| 92 | + container_name: promtail |
| 93 | + restart: unless-stopped |
| 94 | + command: ["-config.file=/etc/promtail/promtail.yaml"] |
| 95 | + volumes: |
| 96 | + - ./promtail/promtail.yaml:/etc/promtail/promtail.yaml:ro |
| 97 | + - /var/run/docker.sock:/var/run/docker.sock:ro |
| 98 | + - promtail-data:/promtail |
| 99 | + depends_on: |
| 100 | + - loki |
| 101 | + |
| 102 | + # ────────────────────────────────────────────── |
| 103 | + # Grafana Loki — Log Aggregation |
| 104 | + # Receives logs from Promtail. |
| 105 | + # ────────────────────────────────────────────── |
| 106 | + loki: |
| 107 | + image: grafana/loki:latest |
| 108 | + container_name: loki |
| 109 | + restart: unless-stopped |
| 110 | + command: ["-config.file=/etc/loki/loki.yaml"] |
| 111 | + volumes: |
| 112 | + - ./loki/loki.yaml:/etc/loki/loki.yaml:ro |
| 113 | + - loki-data:/loki |
| 114 | + ports: |
| 115 | + - "3100:3100" |
| 116 | + |
| 117 | + # ────────────────────────────────────────────── |
| 118 | + # Grafana — Visualization & Dashboards |
| 119 | + # Pre-provisioned with Prometheus, Tempo, and |
| 120 | + # Loki datasources + a Dgraph dashboard. |
| 121 | + # ────────────────────────────────────────────── |
| 122 | + grafana: |
| 123 | + image: grafana/grafana:latest |
| 124 | + container_name: grafana |
| 125 | + restart: unless-stopped |
| 126 | + environment: |
| 127 | + - GF_SECURITY_ADMIN_USER=admin |
| 128 | + - GF_SECURITY_ADMIN_PASSWORD=admin |
| 129 | + - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor tempoSearch tempoServiceGraph traceToMetrics |
| 130 | + - GF_AUTH_ANONYMOUS_ENABLED=true |
| 131 | + - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer |
| 132 | + volumes: |
| 133 | + - ./grafana/provisioning:/etc/grafana/provisioning:ro |
| 134 | + - ./grafana/dashboards:/var/lib/grafana/dashboards:ro |
| 135 | + - grafana-data:/var/lib/grafana |
| 136 | + ports: |
| 137 | + - "3000:3000" |
| 138 | + depends_on: |
| 139 | + - prometheus |
| 140 | + - tempo |
| 141 | + - loki |
| 142 | + |
| 143 | +volumes: |
| 144 | + prometheus-data: |
| 145 | + tempo-data: |
| 146 | + loki-data: |
| 147 | + grafana-data: |
| 148 | + promtail-data: |
0 commit comments