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: 5s
    relabel_configs:
      - source_labels: ['__meta_docker_container_name']
        regex: '/(.*)'
        target_label: 'container'
      - source_labels: ['__meta_docker_container_label_com_docker_swarm_service_name']
        target_label: 'service'
      - source_labels: ['__meta_docker_container_label_com_docker_compose_project']
        target_label: 'project'
      - source_labels: ['__meta_docker_container_name']
        regex: '/?(ai-stack-.*|app-.*opencode.*)'
        action: keep
      - source_labels: ['__meta_docker_container_label_stack_name']
        target_label: 'stack_name'
      - source_labels: ['__meta_docker_container_name']
        regex: '.*opencode-([a-z0-9-]+).*'
        target_label: 'stack_name'
      - source_labels: ['__meta_docker_container_name']
        regex: '.*ai-stack-([a-z0-9-]+).*'
        target_label: 'stack_name'
    pipeline_stages:
      - json:
          expressions:
            output: log
            stream: stream
            timestamp: time
      - labels:
          stream:
      - timestamp:
          source: timestamp
          format: RFC3339Nano
      - output:
          source: output

  - job_name: ai-stack-events
    static_configs:
      - targets:
          - localhost
        labels:
          job: ai-stack-events
          __path__: /var/log/ai-stack/*.jsonl
    pipeline_stages:
      - json:
          expressions:
            stack_name: stack_name
            session_id: session_id
            event_type: event_type
            model: data.model
            agent: data.agent
            tool: data.tool
      - labels:
          stack_name:
          session_id:
          event_type:
          model:
          agent:
          tool:
