server:
  http_listen_address: {{ wireguard_address }}
  http_listen_port: 9080
  grpc_listen_address: 127.0.0.1
  grpc_listen_port: 0 # 0 means random

positions:
  filename: /var/lib/promtail/positions.yaml

clients:
  - url: http://{{ hostvars['monitoring.archlinux.org']['wireguard_address'] }}/loki/api/v1/push
    bearer_token: '{{ vault_loki_token }}'

scrape_configs:
  - job_name: journal
    journal:
      json: true
      max_age: 72h
      path: /var/log/journal
      labels:
        job: systemd-journal
    relabel_configs:
      - source_labels: ["__journal__hostname"]
        target_label: instance
  - job_name: nginx
    static_configs:
      - targets:
        - localhost
        labels:
          job: nginx
          instance: {{ ansible_fqdn }}
          __path__: /var/log/nginx/*/*.json
    pipeline_stages:
    - match:
        selector: '{job="nginx"}'
        stages:
        - json:
            expressions:
              time_local: time_local
        - timestamp:
            format: 02/Jan/2006:15:04:05 -0700
            source: time_local
  - job_name: pacman
    static_configs:
      - targets:
        - localhost
        labels:
          job: pacman
          instance: {{ ansible_fqdn }}
          __path__: /var/log/pacman.log
    pipeline_stages:
    - match:
        selector: '{job="pacman"}'
        stages:
        - regex:
            expression: '^\[(?P<timestamp>.*?)\]'
        - timestamp:
            format: 2006-01-02T15:04:05Z0700
            source: timestamp
