---
apiVersion: v1
kind: ConfigMap
metadata:
  name: promtail-config
  namespace: default
data:
  promtail.yml: |
    scrape_config:
      - job_name: 'kubernetes-pods'
        kubernetes_sd_configs:
          - role: pod

        relabel_configs:
        # Drop pods without a name label
        - source_labels: [__meta_kubernetes_pod_label_name]
          action: drop
          regex: ^$

        # Rename jobs to be <namespace>/<name>, from pod name label
        - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_name]
          action: replace
          separator: /
          target_label: job
          replacement: $1

        # Rename instances to be the pod name
        - source_labels: [__meta_kubernetes_pod_name]
          action: replace
          target_label: instance

        - source_labels: [__meta_kubernetes_pod_uid]
          target_label: "__path__"
          replacement: "/var/log/pods/$1/"
