apiVersion: v1
kind: ConfigMap
metadata:
    name: fluent-bit-config
    labels:
        k8s-app: fluent-bit
data:
    # Configuration files: server, input, filters and output
    # ======================================================
    fluent-bit.conf: |
        [SERVICE]
            Flush         1
            Log_Level     debug
            Daemon        off
            Parsers_File  parsers.conf
            HTTP_Server   On
            HTTP_Listen   0.0.0.0
            HTTP_Port     2020

        @INCLUDE input-kubernetes.conf
        @INCLUDE filter-kubernetes.conf
        @INCLUDE output-timber.conf

    input-kubernetes.conf: |
        [INPUT]
            Name              tail
            Tag               kube.*
            Path              /var/log/containers/*.log
            Exclude_Path      *kube-system*.log
            Parser            docker
            DB                /var/log/flb_kube.db
            Mem_Buf_Limit     5MB
            Skip_Long_Lines   On
            Refresh_Interval  10

    filter-kubernetes.conf: |
        [FILTER]
            Name                kubernetes
            Match               kube.*
            Kube_URL            https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT_HTTPS}
            Merge_Log           On
            K8S-Logging.Parser  On
            tls.verify          Off
            K8S-Logging.Exclude On

    output-timber.conf: |
        [OUTPUT]
            Name            http
            Match           *
            tls             On
            Host            logs.timber.io
            Port            443
            URI     /sources/14331/frames
            Header  Authorization Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2FwaS50aW1iZXIuaW8vIiwiZXhwIjpudWxsLCJpYXQiOjE1NTQzOTY3NTgsImlzcyI6Imh0dHBzOi8vYXBpLnRpbWJlci5pby9hcGlfa2V5cyIsInByb3ZpZGVyX2NsYWltcyI6eyJhcGlfa2V5X2lkIjoxMzcxLCJ1c2VyX2lkIjoiYXBpX2tleXwxMzcxIn0sInN1YiI6ImFwaV9rZXl8MTM3MSJ9.jxTai_GBCQ5C-FtZDUXkrO6YlYJlUwj3yiJNkzvXzyM
            Header  Content-Type application/msgpack
            Format  msgpack
            Retry_Limit 5

    parsers.conf: |
        [PARSER]
            Name        docker
            Format      json
            Time_Key    time
            Time_Format %Y-%m-%dT%H:%M:%S.%L
            Time_Keep   On
            # Command      |  Decoder | Field | Optional Action
            # =============|==================|=================
            Decode_Field_As   escaped    log

