apiVersion: v1
data:
  fluentd-inputs.conf: |
    # HTTP input for the liveness and readiness probes
    <source>
      @type http
      port 9880
    </source>
    # Get the logs from the containers running in the node
    <source>
      @type tail
      path /var/log/containers/*_microsvc-demo_*.log
      # exclude Fluentd logs
      exclude_path /var/log/containers/*fluentd*.log
      pos_file /opt/bitnami/fluentd/logs/buffers/fluentd-docker.pos
      tag kubernetes.*
      read_from_head true
      <parse>
        @type json
        time_key time
        time_format %Y-%m-%dT%H:%M:%S.%NZ
      </parse>
    </source>
    # enrich with kubernetes metadata
    #<filter kubernetes.**>
    #  @type #kubernetes_metadata
    #</filter>
    <filter **>
      @type grep
      <exclude>
        key log
        pattern (healthz|Health|Tracing|Profiling|Profiler|listening|initializing|initialized|Initialization|Microsoft.Hosting|disabled|deprecated|googleapis|currencyservice|1*:C|1*:M|Async|recommendation|env platform|received request|Failed to fetch|\||Small test|small test|"#")
      </exclude>
    </filter>
  fluentd-output.conf: |
    # Throw the healthcheck to the standard output instead of forwarding it
    <match fluentd.healthcheck>
      @type null
    </match>

    <match **>
      #@type stdout
      <server>
        host fluentd-0.fluentd-headless.default.svc.cluster.local
        port 24224
      </server>
      
      @type kafka2
      brokers kafka-spark:9092
      use_event_time true

      # topic settings
      topic_key topic
      default_topic microservices-demo

      # data type settings
      <format>
        @type json
      </format>

      # producer settings
      max_send_retries 1
      required_acks -1
      compression_codec gzip

      # buffer settings
      <buffer>
        @type file
        #path /opt/bitnami/fluentd/logs/buffers-stdout/logs.buffer
        path /opt/bitnami/fluentd/logs/buffers-kafka/logs.buffer
        flush_thread_count 2
        flush_interval 5s
      </buffer>
      
    </match>
  fluentd.conf: |
    # Ignore fluentd own events
    <match fluent.**>
      @type null
    </match>

    @include fluentd-inputs.conf
    @include fluentd-output.conf
  metrics.conf: |
    # Prometheus Exporter Plugin
    # input plugin that exports metrics
    <source>
      @type prometheus
      port 24231
    </source>
    # input plugin that collects metrics from MonitorAgent
    <source>
      @type prometheus_monitor
      <labels>
        host ${hostname}
      </labels>
    </source>
    # input plugin that collects metrics for output plugin
    <source>
      @type prometheus_output_monitor
      <labels>
        host ${hostname}
      </labels>
    </source>
    # input plugin that collects metrics for in_tail plugin
    <source>
      @type prometheus_tail_monitor
      <labels>
        host ${hostname}
      </labels>
    </source>
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: fluentd
    meta.helm.sh/release-namespace: default
  labels:
    app.kubernetes.io/component: forwarder
    app.kubernetes.io/instance: fluentd
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: fluentd
    helm.sh/chart: fluentd-5.0.18
  name: fluentd-forwarder-cm
  namespace: default