server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://loki:3100/loki/api/v1/push
    external_labels:
      source: promtail

scrape_configs:
  - job_name: docker
    docker_sd_configs:
      - host: unix:///var/run/docker.sock
        refresh_interval: 10s
    pipeline_stages:
      - docker: { }
      - labels:
          source: promtail
      - drop:
          older_than: 24h
    relabel_configs:
      - source_labels: [ __meta_docker_container_label_monitor ]
        regex: true
        action: keep

      - source_labels: [ __meta_docker_container_state ]
        regex: running
        action: keep

      - source_labels: [ __meta_docker_container_name ]
        target_label: instance
        regex: ^/(.*)$
        replacement: $1

      - source_labels: [ __meta_docker_container_label_com_docker_compose_service ]
        target_label: service
        replacement: unknown-service

      - source_labels: [ __meta_docker_container_label_com_docker_compose_project ]
        target_label: stack
        replacement: unknown-stack

      - source_labels: [ __meta_docker_container_id ]
        target_label: __path__
        replacement: /var/lib/docker/containers/$1/$1-json.log

      - target_label: job
        replacement: docker

      - target_label: env
        replacement: prod