apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config
  namespace: filebeat
  labels:
    k8s-app: filebeat
data:
  filebeat.yml: |-
    #filebeat.inputs:
    #- type: container
    #  enabled: true
    #  paths:
    #    #- /var/log/containers/*.log
    #    - /u01/data/docker/containers/*/*.log 
    #  processors:
    #    - add_kubernetes_metadata:
    #        host: ${NODE_NAME}
    #        matchers:
    #        - logs_path:
    #            #logs_path: "/var/log/containers/"
    #            logs_path: "/u01/data/docker/containers/"
    # To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this:
    filebeat.autodiscover:
      providers:
        - type: kubernetes
          node: ${NODE_NAME}
          hints.enabled: true
          hints.default_config:
            type: container
            paths:
              #- /var/log/containers/*${data.kubernetes.container.id}.log
              #- /u01/data/docker/containers/*${data.kubernetes.container.id}.log
              - /u01/data/docker/containers/${data.kubernetes.container.id}/*.log
              #- /u01/data/docker/containers/*/*.log
    #filebeat.autodiscover:
    #  providers:
    #    - type: kubernetes
    #      templates:
    #        - condition:
    #            equals: kubernetes.namespace: filebeat
    #          config:
    #            - type: docker
    #              containers.ids:
    #                - "${data.kubernetes.container.id}"

    processors:
      - add_cloud_metadata:
      - add_host_metadata:

    cloud.id: ${ELASTIC_CLOUD_ID}
    cloud.auth: ${ELASTIC_CLOUD_AUTH}

    #output.elasticsearch:
    #  hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
    #  username: ${ELASTICSEARCH_USERNAME}
    #  password: ${ELASTICSEARCH_PASSWORD}
    
    output.logstash:
      hosts: ['${LOGSTASH_HOST}:${LOGSTASH_PORT}']
    
    setup.kibana:
      host: '${KIBANA_HOST}:${KIBANA_PORT}'

    xpack.monitoring:
      enabled: true
      elasticsearch:
        hosts: ['${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}']
        #username: elastic
        #password: changeme
