---
apiVersion: v1
kind: ConfigMap
metadata:
  name: fluentd-config
  namespace: logging
data:
  fluent.conf: |
    <source>
      @type tail
      path /var/log/containers/*.log
      pos_file /var/log/fluentd-containers.log.pos
      tag kubernetes.*
      <parse>
        @type cri
      </parse>
      read_from_head false
    </source>

    <filter kubernetes.**>
      @type kubernetes_metadata
      @id filter_kube_metadata
    </filter>

    <filter **>
      @type elasticsearch_timestamp_check
      subsecond_precision 3
    </filter>

    # Throw away what is not needed first

    #<match fluent.**>
    #@type null
    #</match>

    <match kubernetes.var.log.containers.**kube-system**.log>
      @type null
    </match>

    # Capture what is left
    <match **>
      @type loki
      extract_kubernetes_labels true
      remove_keys kubernetes
      url "http://loki.monitoring:3100"
      flush_interval 10s
      flush_at_shutdown true
      buffer_chunk_limit 1m
    </match>

