apiVersion: v1
kind: ConfigMap
metadata:
  name: newrelic-bundle-newrelic-logging-fluent-bit-config
  namespace: newrelic
  labels:
    k8s-app: newrelic-logging
data:
  # Configuration files: server, input, filters and output
  # ======================================================
  fluent-bit.conf: |
    [SERVICE]
        Flush         1
        Log_Level     ${LOG_LEVEL}
        Daemon        off
        Parsers_File  parsers.conf
        HTTP_Server   On
        HTTP_Listen   0.0.0.0
        HTTP_Port     2020
    @INCLUDE input-kubernetes.conf
    @INCLUDE output-newrelic.conf
    @INCLUDE filter-kubernetes.conf
  input-kubernetes.conf: |
    [INPUT]
        Name                tail
        Tag                 kube.*
        Path                ${PATH}
        DB                  /var/log/flb_kube.db
        Docker_Mode         On
        Docker_Mode_Flush   5
        Docker_Mode_Parser  read_firstline
        parser              docker
        Mem_Buf_Limit       7MB
        Skip_Long_Lines     On
        Refresh_Interval    10
  filter-kubernetes.conf: |
    [FILTER]
        Name           record_modifier
        Match          *
        Record         cluster_name ${CLUSTER_NAME}
    [FILTER]
        Name           kubernetes
        Match          kube.*
        Kube_URL       https://kubernetes.default.svc:443
        K8S-Logging.Exclude ${K8S_LOGGING_EXCLUDE}
  output-newrelic.conf: |
    [OUTPUT]
        Name  newrelic
        Match *
        licenseKey ${LICENSE_KEY}
        endpoint ${ENDPOINT}
  parsers.conf: |
    [PARSER]
        Name                read_firstline
        Format              regex
        Regex /^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) \[(?<start_time>\d+\-\d+\-\d+ \d+\:\d+\:\d+)\] (?<message>.*)/          
        Time_Key            time
        Time_Format %Y-%m-%d %H:%M:%S
