fangli / fluent-plugin-influxdb

A buffered output plugin for fluentd and InfluxDB
MIT License
111 stars 65 forks source link

plugin makes fluentd fail having fluentd 1.15.x and ruby 3 #110

Closed JohnSmall02 closed 1 month ago

JohnSmall02 commented 2 years ago

After updating my fluentd to the latest version (1.15.x), this influxdb plugin makes fluentd fail trying to login to an influxdb.

I use the fluentd image from docker-hub what es provided here -> fluent/fluentd adding some plugins using a Dockerfile and create my own image with it.

The last working version consists out of these fluentd - 1.14.6 fluentd-plugin-influxdb - 2.0.0 (lib) influxdb - 0.7.0 ruby - 2.7.6

everything is just working fine with that.

Failing combination: fluentd - 1.15.2 fluentd-plugin-influxdb - 2.0.0 (lib) influxdb - 0.7.0 ruby - 3.1.2

After upgrading the image to fluentd 1.15.x there is also new version of ruby 3.1.x and with using the same configuration fluentd fails with an exception when trying to login to an influxdb, errorlog:

2022-09-27 09:50:28 +0000 [info]: parsing config file is succeeded path="/fluentd/etc/fluent.conf"
2022-09-27 09:50:28 +0000 [info]: gem 'fluentd' version '1.15.2'
2022-09-27 09:50:28 +0000 [info]: gem 'fluent-plugin-influxdb' version '2.0.0'
2022-09-27 09:50:28 +0000 [info]: gem 'fluent-plugin-prometheus' version '2.0.3'
2022-09-27 09:50:28 +0000 [info]: gem 'fluent-plugin-s3' version '1.7.1'
2022-09-27 09:50:28 +0000 [info]: gem 'fluent-plugin-suppress' version '1.1.0'
2022-09-27 09:50:28 +0000 [info]: gem 'fluent-plugin-systemd' version '1.0.5'
2022-09-27 09:50:28 +0000 [trace]: registered output plugin 'copy'
2022-09-27 09:50:28 +0000 [trace]: registered metrics plugin 'local'
2022-09-27 09:50:28 +0000 [debug]: adding store type="relabel"
2022-09-27 09:50:28 +0000 [trace]: registered output plugin 'relabel'
2022-09-27 09:50:28 +0000 [debug]: adding store type="relabel"
2022-09-27 09:50:28 +0000 [debug]: adding store type="relabel"
2022-09-27 09:50:28 +0000 [trace]: registered filter plugin 'grep'
2022-09-27 09:50:28 +0000 [trace]: registered filter plugin 'record_transformer'
2022-09-27 09:50:28 +0000 [trace]: registered output plugin 'file'
2022-09-27 09:50:28 +0000 [trace]: registered buffer plugin 'file'
2022-09-27 09:50:28 +0000 [trace]: registered formatter plugin 'json'
2022-09-27 09:50:28 +0000 [trace]: registered output plugin 'influxdb'
2022-09-27 09:50:28 +0000 [trace]: registered buffer plugin 'memory'
2022-09-27 09:50:28 +0000 [trace]: registered output plugin 'stdout'
2022-09-27 09:50:28 +0000 [trace]: registered formatter plugin 'stdout'
2022-09-27 09:50:28 +0000 [trace]: registered input plugin 'forward'
2022-09-27 09:50:28 +0000 [trace]: registered input plugin 'prometheus'
2022-09-27 09:50:28 +0000 [debug]: No fluent logger for internal event
2022-09-27 09:50:28 +0000 [info]: using configuration file: <ROOT>
  <system>
    log_level trace
  </system>
  <source>
    @type forward
    @id input1
    @label @logs
    port 14224
  </source>

... cut ...

  <label @influx>
    <filter **>
      @type grep
      <exclude>
        key "log"
        pattern /Lock owner|I am \(.*\) the leader with the lock|I am a secondary \(.*\) and following a leader/
      </exclude>
    </filter>
    <filter **>
      @type record_transformer
      enable_ruby
      remove_keys container_id, container_name
      <record>
        host ${tag.split('-').first}
        instance ${tag.split('-').last}
      </record>
    </filter>
    <match *-*>
      @type influxdb
      @id influxdb
      host "fqdn.hostname"
      port 8086
      dbname "dbname"
      measurement "db_log"
      user "user"
      password xxxxxx
      use_ssl false
      time_precision "s"
      tag_keys ["host","instance"]
      <buffer>
        @type "memory"
        flush_interval 60
        flush_at_shutdown true
      </buffer>
    </match>
  </label>
  <label @ERROR>
    <match **>
      @type stdout
    </match>
  </label>
</ROOT>
2022-09-27 09:50:28 +0000 [info]: starting fluentd-1.15.2 pid=7 ruby="3.1.2"
2022-09-27 09:50:28 +0000 [info]: spawn command to main:  cmdline=["/usr/local/bin/ruby", "-Eascii-8bit:ascii-8bit", "/usr/local/bundle/bin/fluentd", "--config", "/fluentd/etc/fluent.conf", "--plugin", "/fluentd/plugins", "--under-supervisor"]
2022-09-27 09:50:28 +0000 [info]: adding match in @logs pattern="**" type="copy"
2022-09-27 09:50:28 +0000 [trace]: #0 registered output plugin 'copy'
2022-09-27 09:50:28 +0000 [trace]: #0 registered metrics plugin 'local'
2022-09-27 09:50:28 +0000 [debug]: #0 adding store type="relabel"
2022-09-27 09:50:28 +0000 [trace]: #0 registered output plugin 'relabel'
2022-09-27 09:50:28 +0000 [debug]: #0 adding store type="relabel"
2022-09-27 09:50:28 +0000 [debug]: #0 adding store type="relabel"
2022-09-27 09:50:28 +0000 [info]: adding filter in @data pattern="**pc**" type="grep"
2022-09-27 09:50:28 +0000 [trace]: #0 registered filter plugin 'grep'
2022-09-27 09:50:28 +0000 [info]: adding filter in @data pattern="**pc**" type="record_transformer"
2022-09-27 09:50:28 +0000 [trace]: #0 registered filter plugin 'record_transformer'
2022-09-27 09:50:28 +0000 [info]: adding match in @data pattern="**pc**" type="file"
2022-09-27 09:50:28 +0000 [trace]: #0 registered output plugin 'file'
2022-09-27 09:50:28 +0000 [trace]: #0 registered buffer plugin 'file'
2022-09-27 09:50:28 +0000 [trace]: #0 registered formatter plugin 'json'
2022-09-27 09:50:28 +0000 [info]: adding filter in @all pattern="**" type="grep"
2022-09-27 09:50:28 +0000 [info]: adding filter in @all pattern="**" type="record_transformer"
2022-09-27 09:50:28 +0000 [info]: adding match in @all pattern="**" type="file"
2022-09-27 09:50:28 +0000 [info]: adding filter in @influx pattern="**" type="grep"
2022-09-27 09:50:28 +0000 [info]: adding filter in @influx pattern="**" type="record_transformer"
2022-09-27 09:50:28 +0000 [info]: adding match in @influx pattern="*-*" type="influxdb"
2022-09-27 09:50:28 +0000 [trace]: #0 registered output plugin 'influxdb'
2022-09-27 09:50:28 +0000 [trace]: #0 registered buffer plugin 'memory'
2022-09-27 09:50:28 +0000 [info]: adding match in @ERROR pattern="**" type="stdout"
2022-09-27 09:50:28 +0000 [trace]: #0 registered output plugin 'stdout'
2022-09-27 09:50:28 +0000 [trace]: #0 registered formatter plugin 'stdout'
2022-09-27 09:50:28 +0000 [info]: adding source type="forward"
2022-09-27 09:50:28 +0000 [trace]: #0 registered input plugin 'forward'
2022-09-27 09:50:28 +0000 [info]: adding source type="prometheus"
2022-09-27 09:50:28 +0000 [trace]: #0 registered input plugin 'prometheus'
2022-09-27 09:50:28 +0000 [debug]: #0 No fluent logger for internal event
2022-09-27 09:50:28 +0000 [info]: #0 starting fluentd worker pid=17 ppid=7 worker=0
2022-09-27 09:50:28 +0000 [debug]: #0 [influxdb] buffer started instance=2420 stage_size=0 queue_size=0
2022-09-27 09:50:28 +0000 [info]: #0 [influxdb] Connecting to database: dbname, host: fqdn.hostname, port: 8086, username: user, use_ssl = false, verify_ssl = true
2022-09-27 09:50:28 +0000 [error]: #0 unexpected error error_class=ArgumentError error="wrong number of arguments (given 1, expected 0)"
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/influxdb-0.7.0/lib/influxdb/config.rb:73:in `initialize'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/influxdb-0.7.0/lib/influxdb/client.rb:54:in `new'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/influxdb-0.7.0/lib/influxdb/client.rb:54:in `initialize'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluent-plugin-influxdb-2.0.0/lib/fluent/plugin/out_influxdb.rb:83:in `new'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluent-plugin-influxdb-2.0.0/lib/fluent/plugin/out_influxdb.rb:83:in `start'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/root_agent.rb:203:in `block in start'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/root_agent.rb:182:in `block (2 levels) in lifecycle'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/agent.rb:121:in `block (2 levels) in lifecycle'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/agent.rb:120:in `each'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/agent.rb:120:in `block in lifecycle'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/agent.rb:113:in `each'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/agent.rb:113:in `lifecycle'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/root_agent.rb:181:in `block in lifecycle'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/root_agent.rb:178:in `each'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/root_agent.rb:178:in `lifecycle'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/root_agent.rb:202:in `start'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/engine.rb:248:in `start'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/engine.rb:147:in `run'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/supervisor.rb:764:in `block in run_worker'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/supervisor.rb:1037:in `main_process'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/supervisor.rb:755:in `run_worker'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/lib/fluent/command/fluentd.rb:381:in `<top (required)>'
  2022-09-27 09:50:28 +0000 [error]: #0 <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
  2022-09-27 09:50:28 +0000 [error]: #0 <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/gems/fluentd-1.15.2/bin/fluentd:15:in `<top (required)>'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/bin/fluentd:25:in `load'
  2022-09-27 09:50:28 +0000 [error]: #0 /usr/local/bundle/bin/fluentd:25:in `<main>'
2022-09-27 09:50:28 +0000 [error]: #0 unexpected error error_class=ArgumentError error="wrong number of arguments (given 1, expected 0)"
  2022-09-27 09:50:28 +0000 [error]: #0 suppressed same stacktrace
2022-09-27 09:50:29 +0000 [error]: fluent/log.rb:372:error: Worker 0 finished unexpectedly with status 1
2022-09-27 09:50:29 +0000 [info]: adding match in @logs pattern="**" type="copy"

# from here on the log repeats itself until you stop fluentd/the container!

find the exception at the bottom part of the log. line to focus on is 2022-09-27 09:50:28 +0000 [error]: #0 unexpected error error_class=ArgumentError error="wrong number of arguments (given 1, expected 0)" Here we an see that the exception is actually coming from the lib influxdb 0.7.0, and after investigating it turns out that there would be a newer version of the lib available, and in the commit message we can find that in influxdb 0.8.1 there was ruby 3.x support added what sounds to be a nice approach to check this out.

The newer version is not used by the fluent-plugin-influxdb as the lib influxdb in 0.8.1 did not exist in 2019 when the plugin was released, and the runtime_dependency is set to "influxdb", [">= 0.7.0", "< 0.8"]

link to ruby lib influxdb link to fluent/fluentd github for the docker image

Hope we can put this plugin forward with the current version of ruby and fluentd.

kind regards.

JohnSmall02 commented 2 years ago

I'll post this real quick, as a smart repair it is possible to install the ruby lib influxdb right after installing the fluent-plugin-influxdb and its working just fine. Versions are then fluentd - 1.15.2 fluentd-plugin-influxdb - 2.0.0 (lib) influxdb - 0.8.1 ruby - 3.1.2

gem install influxdb -v 0.8.1 --no-document

conclusioin, when the runtime_dependency could be changed to include the latest version of the ruby lib influxdb then we're good to go I guess.

kthxbye

LinusHansTryggveEriksson commented 1 year ago

Thank god, I was starting to go crazy! In case anyone wonders, if you are using the fluent helm chart you can list the influxdb lib as a plugin.