---
apiVersion: v1
kind: ConfigMap
metadata:
  name: promtail
data:
  promtail.yaml: |
    server:
      http_listen_port: 3101
    clients:
    - url: http://loki:3100/loki/api/v1/push
    positions:
      filename: /run/promtail/positions.yaml

    scrape_configs:

    - job_name: kubernetes-pods
      kubernetes_sd_configs:
      - role: pod
      relabel_configs:
      - action: keep
        regex: ''
        source_labels:
        - __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
      - target_label: __path__
        source_labels:
        - __meta_kubernetes_pod_uid
        - __meta_kubernetes_pod_container_name
        separator: /
        replacement: /var/log/pods/*$1/*.log
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
      - target_label: pod
        action: replace
        source_labels:
        - __meta_kubernetes_pod_name
      - target_label: container
        action: replace
        source_labels:
        - __meta_kubernetes_pod_container_name

    - job_name: kubernetes-static-pods
      kubernetes_sd_configs:
      - role: pod
      relabel_configs:
      - action: drop
        regex: ''
        source_labels:
        - __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
      - target_label: __path__
        source_labels:
        - __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
        - __meta_kubernetes_pod_container_name
        separator: /
        replacement: /var/log/pods/*$1/*.log
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
      - target_label: pod
        action: replace
        source_labels:
        - __meta_kubernetes_pod_name
      - target_label: container
        action: replace
        source_labels:
        - __meta_kubernetes_pod_container_name
        - __meta_kubernetes_pod_container_name
