From 5a19217b334511642823ac45849334f74b46e4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Sun, 5 Apr 2026 15:23:41 +0200 Subject: [PATCH] Add Promtail to ship Docker container logs to Loki MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Loki was running but had no log shipper — no labels or logs were visible in Grafana. Adds Promtail to scrape all Docker container logs and push them to Loki. Co-Authored-By: Claude Opus 4.6 (1M context) --- infrastructure/docker-compose.yml | 11 +++++++++++ infrastructure/promtail/promtail-config.yml | 22 +++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 infrastructure/promtail/promtail-config.yml diff --git a/infrastructure/docker-compose.yml b/infrastructure/docker-compose.yml index 722b49b..d8b61b7 100644 --- a/infrastructure/docker-compose.yml +++ b/infrastructure/docker-compose.yml @@ -128,6 +128,17 @@ services: - /var/lib/docker/:/var/lib/docker:ro - /dev/disk/:/dev/disk:ro + promtail: + image: grafana/promtail:latest + restart: unless-stopped + volumes: + - /var/log:/var/log:ro + - /var/lib/docker/containers:/var/lib/docker/containers:ro + - ./promtail/promtail-config.yml:/etc/promtail/config.yml:ro + command: ["-config.file=/etc/promtail/config.yml"] + depends_on: + - loki + prometheus: image: prom/prometheus:latest restart: unless-stopped diff --git a/infrastructure/promtail/promtail-config.yml b/infrastructure/promtail/promtail-config.yml new file mode 100644 index 0000000..f7414fe --- /dev/null +++ b/infrastructure/promtail/promtail-config.yml @@ -0,0 +1,22 @@ +server: + http_listen_port: 9080 + grpc_listen_port: 0 + +positions: + filename: /tmp/positions.yaml + +clients: + - url: http://loki:3100/loki/api/v1/push + +scrape_configs: + - job_name: docker + static_configs: + - targets: + - localhost + labels: + job: docker + __path__: /var/lib/docker/containers/*/*.log + pipeline_stages: + - docker: {} + - labeldrop: + - filename