Ведение Kubernetes с помощью fluentd daemonset - PullRequest
0 голосов
/ 11 июля 2019

Мой fluentd-daemonset настроен в кластере kubernetes для отправки журналов в cloudwatch.Я следовал этому учебнику и установил свободное владение.Однако в cloudwatch я вижу, что я также вижу логи по fluentd.Как я могу остановить отправку журналов fluentd в cloudwatch?

Это конфигурационный файл, который я использую,

<source>
  @type tail
  @id in_tail_container_logs
  @label @containers
  path /var/log/containers/*.log
  pos_file /var/log/fluentd-containers.log.pos
  tag *
  read_from_head true
  <parse>
    @type json
    time_format %Y-%m-%dT%H:%M:%S.%NZ
  </parse>
</source>

<label @containers>
  <filter **>
    @type kubernetes_metadata
    @id filter_kube_metadata
  </filter>

  <filter **>
    @type record_transformer
    @id filter_containers_stream_transformer
    <record>
      stream_name ${tag_parts[3]}
    </record>
  </filter>

  <match **>
    @type cloudwatch_logs
    @id out_cloudwatch_logs_containers
    region "#{ENV.fetch('REGION')}"
    log_group_name "/eks/#{ENV.fetch('CLUSTER_NAME')}/containers"
    log_stream_name_key stream_name
    remove_log_stream_name_key true
    auto_create_stream true
    retention_in_days "#{ENV.fetch('RETENTION_IN_DAYS')}"
    <buffer>
      flush_interval 5
      chunk_limit_size 2m
      queued_chunks_limit_size 32
      retry_forever true
    </buffer>
  </match>
</label>

Ответы [ 2 ]

0 голосов
/ 11 июля 2019

Должно работать в соответствии с аннотацией:

<match fluent.**>
  @type null
</match>

Например, для следующих настроек:

<match fluent.**>
  @type file
  path /var/log/internal/my-fluentd.log
  compress gzip
</match>

Согласно документации, вы можете исключить эти журналы, используя эту конфигурацию:

exclude_path ["/var/log/internal/*.gz"]
0 голосов
/ 11 июля 2019

Я исключил журналы fluentd с exclude_path в конфигурации следующим образом, и теперь я не получаю их.

<source>
  @type tail
  @id in_tail_container_logs
  @label @containers
  path /var/log/containers/*.log
  pos_file /var/log/fluentd-containers.log.pos
  exclude_path ["/var/log/containers/*fluentd*"]
  tag *
  read_from_head true
  <parse>
    @type json
    time_format %Y-%m-%dT%H:%M:%S.%NZ
  </parse>
</source>
...