# Promtail Configuration Template
# Copy this file to ./config/promtail/promtail-config.yml

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:
  # Docker container logs
  - job_name: docker
    static_configs:
      - targets:
          - localhost
        labels:
          job: docker
          __path__: /var/lib/docker/containers/*/*-json.log

    pipeline_stages:
      # Parse Docker JSON logs
      - json:
          expressions:
            output: log
            stream: stream
            attrs: attrs
      
      # Extract container name from path
      - regex:
          expression: '/var/lib/docker/containers/(?P<container_id>[^/]+)/.*'
          source: filename
      
      # Add labels
      - labels:
          stream:
          container_id:
      
      # Output the log line
      - output:
          source: output

  # System logs (optional)
  # - job_name: system
  #   static_configs:
  #     - targets:
  #         - localhost
  #       labels:
  #         job: varlogs
  #         __path__: /var/log/*.log
