trails/infrastructure/promtail/promtail-config.yml
Ullrich Schäfer 1433997d5b Fix journal health check and improve log collection
Switch journal Docker health check from `node -e "fetch(...)"` to `curl -sf`,
matching the planner. The Node.js process spawn was heavy and prone to timeout
under memory pressure, causing false health check failures and 502s.

Upgrade Promtail from static file scraping to Docker service discovery so logs
get `service` and `container` labels. Parse Pino JSON logs to extract the
`level` label, enabling Loki queries filtered by log level.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 15:00:00 +02:00

39 lines
1.2 KiB
YAML

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
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 10s
relabel_configs:
# Use the container name as a label
- source_labels: ["__meta_docker_container_name"]
regex: "/?(.*)"
target_label: container
# Use the compose service name if available
- source_labels: ["__meta_docker_container_label_com_docker_compose_service"]
target_label: service
# Drop containers we don't need logs from (exporters, promtail itself)
- source_labels: ["__meta_docker_container_label_com_docker_compose_service"]
regex: "promtail|node-exporter|cadvisor|postgres-exporter"
action: drop
pipeline_stages:
- docker: {}
# Parse Pino JSON logs (journal, planner) to extract level
- match:
selector: '{service=~"journal|planner"}'
stages:
- json:
expressions:
level: level
msg: msg
- labels:
level: