From 63c6a648d78edaceacae1d924c41873936708e47 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 4 Dec 2025 20:06:24 +0000 Subject: [PATCH] Add Loki, Promtail, and Grafana services for observability stack --- docker/docker-compose.prod.yml | 47 +++++++++++++++++++ docker/loki-config/local-config.yaml | 43 +++++++++++++++++ .../loki-data/chunks/loki_cluster_seed.json | 1 + 3 files changed, 91 insertions(+) create mode 100644 docker/loki-config/local-config.yaml create mode 100644 docker/loki-data/chunks/loki_cluster_seed.json diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index da5b859d..1808f0c5 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -61,11 +61,58 @@ services: timeout: 10s retries: 3 + # Optional local observability stack (can be enabled on servers that + # should run Loki/Grafana). These services use configs found under + # the repository `docker/` directory so the same config works in dev. + loki: + image: grafana/loki:2.8.2 + command: -config.file=/etc/loki/local-config.yaml + ports: + - "3100:3100" + volumes: + - ./loki-config/local-config.yaml:/etc/loki/local-config.yaml:ro + - ../docker/loki-data:/loki + # WAL directory: map a host folder so Loki (running as UID 10001) + # can create the write-ahead log. Host folder created under + # `docker/loki-wal` and owned by UID 10001. + - ../docker/loki-wal:/wal + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "wget -qO- http://localhost:3100/ready || exit 1"] + interval: 10s + timeout: 5s + retries: 6 + + promtail: + image: grafana/promtail:2.8.2 + volumes: + # In prod you may want to point this at the host system log directory. + - ../logs:/var/log/rad:ro + - ./promtail-config.yml:/etc/promtail/promtail-config.yml:ro + command: -config.file=/etc/promtail/promtail-config.yml + depends_on: + - loki + restart: unless-stopped + + grafana: + image: grafana/grafana:10.2.0 + ports: + - "3000:3000" + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + volumes: + - grafana-data:/var/lib/grafana + depends_on: + loki: + condition: service_healthy + restart: unless-stopped + volumes: postgres_data: redis_data: static_volume: media_volume: + grafana-data: networks: default: diff --git a/docker/loki-config/local-config.yaml b/docker/loki-config/local-config.yaml new file mode 100644 index 00000000..8b3b7b2f --- /dev/null +++ b/docker/loki-config/local-config.yaml @@ -0,0 +1,43 @@ +server: + http_listen_port: 3100 + grpc_listen_port: 9095 + +ingester: + lifecycler: + address: 127.0.0.1 + ring: + kvstore: + store: inmemory + replication_factor: 1 + chunk_idle_period: 5m + chunk_retain_period: 30s + max_transfer_retries: 0 + +schema_config: + configs: + - from: 2020-10-24 + store: boltdb-shipper + object_store: filesystem + schema: v11 + index: + prefix: index_ + period: 24h + +storage_config: + boltdb_shipper: + active_index_directory: /loki/index + cache_location: /loki/cache + shared_store: filesystem + filesystem: + directory: /loki/chunks + +# Compactor settings: ensure compactor working directory is inside the mounted +# `/loki` path so the process (running as UID 10001) can create files. +compactor: + working_directory: /loki/compactor + shared_store: filesystem + +limits_config: + enforce_metric_name: false + +auth_enabled: false diff --git a/docker/loki-data/chunks/loki_cluster_seed.json b/docker/loki-data/chunks/loki_cluster_seed.json new file mode 100644 index 00000000..037f8b98 --- /dev/null +++ b/docker/loki-data/chunks/loki_cluster_seed.json @@ -0,0 +1 @@ +{"UID":"f8cade59-3cf9-4ae3-965d-8b0a57007d58","created_at":"2025-12-01T17:14:05.101735276Z","version":{"version":"2.8.2","revision":"9f809eda7","branch":"HEAD","buildUser":"root@e401cfcb874f","buildDate":"2023-05-03T11:07:54Z","goVersion":"go1.20.4"}} \ No newline at end of file