fluent / fluentd-docs-gitbook

Fluentd documentation project in Gitbook format
https://docs.fluentd.org
Apache License 2.0
44 stars 130 forks source link

Can not use "file" plugin as secondary for "elasticsearch" #131

Open Gleb-ho opened 4 years ago

Gleb-ho commented 4 years ago

As mentioned in the docs the user can specify with any output plugin in . There is an example:

<match my.logs>
  @type elasticsearch
  host localhost
  port 9200
  logstash_format true
  <buffer>
    @type file
    path /var/log/td-agent/buffer/elasticsearch
  </buffer>
  <secondary>
    @type file
    path /var/log/td-agent/error/my.logs
  </secondary>
</match>

But this example config follows with this warn message:

[warn]: #0 secondary type should be same with primary one primary="Fluent::Plugin::ElasticsearchOutput" secondary="Fluent::Plugin::FileOutput"

Nothing is delegated to file plugin as expected.

Posting the complete log:


2019-12-24 15:17:29 +0000 [info]: parsing config file is succeeded path="/etc/td-agent/td-agent.conf"
2019-12-24 15:17:36 +0000 [warn]: secondary type should be same with primary one primary="Fluent::Plugin::ElasticsearchOutput" secondary="Fluent::Plugin::FileOutput"
2019-12-24 15:17:36 +0000 [warn]: To prevent events traffic jam, you should specify 2 or more 'flush_thread_count'.
2019-12-24 15:17:36 +0000 [info]: using configuration file: <ROOT>
  <source>
    @type forward
    tag "direct.*"
    port 24224
  </source>
  <match fluent.**>
    @type null
  </match>
  <source>
    @type tail
    path "/var/log/containers/*.log"
    pos_file "/var/lib/fluentd/es-containers.log.pos"
    time_format %Y-%m-%dT%H:%M:%S.%NZ
    tag "kubernetes.*"
    format json
    read_from_head true
    <parse>
      time_format %Y-%m-%dT%H:%M:%S.%NZ
      @type json
      time_type string
    </parse>
  </source>
  <filter kubernetes.**>
    @type kubernetes_metadata
  </filter>
  <match *.**>
    @type elasticsearch
    host "localhost"
    port 9200
    logstash_format true
    <buffer>
      @type "file"
      path "/var/log/td-agent/buffer/elasticsearch"
    </buffer>
    <secondary>
      @type "file"
      path "/var/log/td-agent/error/my.logs"
      <buffer time>
        path /var/log/td-agent/error/my.logs
      </buffer>
    </secondary>
  </match>
</ROOT>
2019-12-24 15:17:36 +0000 [info]: starting fluentd-1.7.4 pid=1 ruby="2.4.9"
2019-12-24 15:17:36 +0000 [info]: spawn command to main:  cmdline=["/opt/td-agent/embedded/bin/ruby", "-Eascii-8bit:ascii-8bit", "/usr/sbin/td-agent", "-c", "/etc/td-agent/td-agent.conf", "--under-supervisor"]
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-elasticsearch' version '3.5.5'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-kafka' version '0.12.1'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-kubernetes_metadata_filter' version '2.4.0'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-prometheus' version '1.7.0'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-record-modifier' version '2.0.1'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-rewrite-tag-filter' version '2.2.0'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-s3' version '1.2.0'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-td' version '1.0.0'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-td-monitoring' version '0.2.4'
2019-12-24 15:17:39 +0000 [info]: gem 'fluent-plugin-webhdfs' version '1.2.4'
2019-12-24 15:17:39 +0000 [info]: gem 'fluentd' version '1.7.4'
2019-12-24 15:17:39 +0000 [info]: adding match pattern="fluent.**" type="null"
2019-12-24 15:17:39 +0000 [info]: adding filter pattern="kubernetes.**" type="kubernetes_metadata"
2019-12-24 15:17:43 +0000 [info]: adding match pattern="*.**" type="elasticsearch"
2019-12-24 15:17:47 +0000 [warn]: #0 secondary type should be same with primary one primary="Fluent::Plugin::ElasticsearchOutput" secondary="Fluent::Plugin::FileOutput"
2019-12-24 15:17:49 +0000 [warn]: #0 Could not communicate to Elasticsearch, resetting connection and trying again. Cannot assign requested address - connect(2) for [::1]:9200 (Errno::EADDRNOTAVAIL)
repeatedly commented 4 years ago

Current log message is misleading. Send a patch: https://github.com/fluent/fluentd/pull/2751

clacsinaRX-M commented 4 years ago

On the docs, would it be clearer say:

In buffered mode, the user can specify <secondary> with almost any output plugin in <match> configuration. If plugins continue to fail writing buffer chunks and exceeds the timeout threshold for retries, then output plugins will delegate to write the buffer chunk to secondary plugin.

<secondary> is useful for backup when destination servers are unavailable, e.g. forward, mongo and other plugins. We strongly recommend out_secondary_file plugin for <secondary>.

The following output plugins do not work under the <secondary> configuration: - out_file - Use out_secondary_file instead

@repeatedly Are there any other output plugins that do not work with <secondary>?