<filter kubernetes.**>
  type kubernetes_metadata
  kubernetes_url "#{ENV['K8S_HOST_URL']}"
  cache_size "#{ENV['K8S_METADATA_CACHE_SIZE'] || '1000'}"
  watch "#{ENV['K8S_METADATA_WATCH'] || 'false'}"
  bearer_token_file /var/run/secrets/kubernetes.io/serviceaccount/token
  ca_file /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
  use_journal "#{ENV['USE_JOURNAL'] || 'nil'}"
  container_name_to_kubernetes_regexp '^(?<name_prefix>[^_]+)_(?<container_name>[^\._]+)(\.(?<container_hash>[^_]+))?_(?<pod_name>[^_]+)_(?<namespace>[^_]+)_[^_]+_[^_]+$'
</filter>

<filter kubernetes.journal.**>
  @type parse_json_field
  merge_json_log "#{ENV['MERGE_JSON_LOG'] || 'false'}"
  preserve_json_log "#{ENV['PRESERVE_JSON_LOG'] || 'true'}"
  json_fields "#{ENV['JSON_FIELDS'] || 'MESSAGE,log'}"
</filter>

<filter kubernetes.var.log.containers.**>
  @type parse_json_field
  merge_json_log "#{ENV['MERGE_JSON_LOG'] || 'false'}"
  preserve_json_log "#{ENV['PRESERVE_JSON_LOG'] || 'true'}"
  json_fields "#{ENV['JSON_FIELDS'] || 'log,MESSAGE'}"
</filter>
