---
apiVersion: v1
kind: ConfigMap
metadata:
  name: splunk-kubernetes-metrics
  labels:
    app: splunk-kubernetes-metrics
    version: 1.4.7
data:
  fluent.conf: |
    # system wide configurations
    <system>
      log_level info
    </system>
    <source>
      @type kubernetes_metrics
      tag kube.*
      node_name "#{ENV['NODE_NAME']}"
      use_rest_client_ssl true
      cluster_name cluster_name
      interval 15s
    </source>
    <filter kube.**>
      @type record_modifier
      <record>
        metric_name ${tag}
        cluster_name cluster_name
      </record>
    </filter>
    <filter kube.node.**>
      @type record_modifier
      <record>
        source ${record['node']}
      </record>
    </filter>
    <filter kube.pod.**>
      @type record_modifier
      <record>
        source ${record['node']}/${record['pod-name']}
      </record>
    </filter>
    <filter kube.sys-container.**>
      @type record_modifier
      <record>
        source ${record['node']}/${record['pod-name']}/${record['name']}
      </record>
    </filter>
    <filter kube.container.**>
      @type record_modifier
      <record>
        source ${record['node']}/${record['pod-name']}/${record['container-name']}
      </record>
    </filter>
    # = custom filters specified by users =
    <match kube.**>
      @type splunk_hec
      data_type metric
      metric_name_key metric_name
      metric_value_key value
      protocol https
      hec_host "MY-SPLUNK-HOST"
      hec_port 8088
      hec_token "#{ENV['SPLUNK_HEC_TOKEN']}"
      host "#{ENV['NODE_NAME']}"
      source ${tag}
      insecure_ssl true
      app_name splunk-kubernetes-metrics
      app_version 1.4.7
      <buffer>
        @type memory
        chunk_limit_records 10000
        chunk_limit_size 10m
        flush_interval 5s
        flush_thread_count 1
        overflow_action block
        retry_max_times 5
        retry_type periodic
        total_limit_size 400m
      </buffer>
    </match>
