Fluentdのout_copyのstoreのエラーは他のstoreに影響する

fluentd

Fluentdのout_copyプラグインは 一つのeventを複数のoutputに渡すために使われる。 ただ、複数設定した中のstoreでエラーが起きると他のstoreにも影響してしまう。

例えばこんなの。

<source>
  @type dummy
  dummy {"hello":"world"}
  tag dummy
  rate 1
</source>

<match dummy>
  @type copy

  <store>
    @type stdout
  </store>

  <store>
    @type file
    path /var/log/td-agent/dummy
    buffer_queue_limit 0
    buffer_chunk_limit 1k
  </store>
</match>

fileの方で queue size exceeds limit になるとstdoutも出力されなくなってしまう。

ちなみに一旦relabelしてもだめ。

<source>
  @type dummy
  dummy {"hello":"world"}
  tag dummy
  rate 1
</source>

<match dummy>
  @type copy

  <store>
    @type stdout
  </store>

  <store>
    @type relabel
    @label @file
  </store>
</match>

<label @file>
  <match dummy>
    @type file
    path /var/log/td-agent/dummy
    buffer_queue_limit 0
    buffer_chunk_limit 1k
  </match>
</label>

ドキュメントでも紹介されている、sonots氏のout_copy_exでは storeにignore_errorを付けるとrescueするようになっているので他に巻き込まれなくなる。

$ td-agent-gem install fluent-plugin-copy_ex
<source>
  @type dummy
  dummy {"hello":"world"}
  tag dummy
  rate 1
</source>

<match dummy>
  @type copy_ex

  <store ignore_error>
    @type stdout
  </store>

  <store ignore_error>
    @type file
    path /var/log/td-agent/dummy
    buffer_queue_limit 0
    buffer_chunk_limit 1k
  </store>
</match>
dummy: {"hello":"world"}
[error]:  error_class=Fluent::BufferQueueLimitError error="queue size exceeds limit"
dummy: {"hello":"world"}
[error]:  error_class=Fluent::BufferQueueLimitError error="queue size exceeds limit"