---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat
  namespace: filebeat
  labels:
    app: filebeat
data:
  filebeat.yml: |-
    filebeat.autodiscover:
      providers:
        - type: kubernetes
          node: ${NODE_NAME}
          hints.enabled: true
          hints.default_config:
            type: container
            close_inactive: 12h
            paths:
              - /var/log/containers/*${data.kubernetes.container.id}.log

    queue:
      mem:
        events: 100000
        flush.min_events: 50000
        flush.timeout: 60s

    processors:
      - decode_json_fields:
          fields: ["message"]
          process_array: false
          max_depth: 3
          target: "content"
          overwrite_keys: false
          add_error_key: true

    output.clickhouse:
      cluster: ${CLUSTER}
      address: clickhouse-clickhouse.clickhouse.svc.cluster.local:9000
      database: logs
      username: admin
      password: admin
      write_timeout: "20"
      read_timeout: "10"
      async_insert: true
      wait_for_async_insert: true
      force_number_fields:
        - content.duration
        - content.upstream_service_time

    logging.level: "${LOG_LEVEL:info}"
    logging.metrics.enabled: false
    logging.json: true

    http:
      enabled: true
      host: 0.0.0.0
      port: 5066
