apiVersion: v1
kind: ConfigMap
metadata:
  name: fluentd-aggregator
data:
  fluentd.conf: |

    # Ignore fluentd own events
    <label @FLUENT_LOG>
      <match fluent.**>
        @type null
      </match>
    </label>

    # TCP input to receive logs from the forwarders
    <source>
      @type forward
      bind 0.0.0.0
      port 24224
    </source>

    # HTTP input for the liveness and readiness probes
    <source>
      @type http
      bind 0.0.0.0
      port 9880
    </source>

    # Throw the healthcheck to the standard output instead of forwarding it
    <match fluentd.healthcheck>
      @type null
    </match>

    # Send the logs to the Elasticsearch
    <match **>
       @type elasticsearch
       @id out_es
       @log_level info
       include_tag_key true
       host "#{ENV['ELASTICSEARCH_HOST']}"
       port "#{ENV['ELASTICSEARCH_PORT']}"
       path "#{ENV['ELASTICSEARCH_PATH']}"
       scheme "http"
       ssl_verify "true"
       ssl_version "TLSv1"
       reload_connections "false"     
       reconnect_on_error "true"      
       reload_on_failure "true"
       log_es_400_reason "false"       
       logstash_prefix "logstash"
       logstash_format "true"
       type_name "fluentd"
       suppress_type_name true
       request_timeout 30s
       <buffer>
         flush_thread_count "8"
         flush_interval "5s"
         chunk_limit_size "6M"
         queue_limit_length "32"
         retry_max_interval "30"
         retry_forever true
       </buffer>
    </match>
