fluent/fluent-plugin-sql

error="undefined method `key' for #<Fluent::Plugin::Buffer::MemoryChunk:0x00007fa50795d6d0>"

PhML opened this issue · 0 comments

PhML commented

I want to insert some logs in postgres but I get an error.
Here are the logs:

fluentd-g     | 2019-11-15 15:18:47 +0000 [info]: starting fluentd-1.6.3 pid=6 ruby="2.6.3"
fluentd-g     | 2019-11-15 15:18:47 +0000 [info]: spawn command to main:  cmdline=["/usr/local/bin/ruby", "-Eascii-8bit:ascii-8bit", "/usr/local/bundle/bin/fluentd", "-c", "/fluentd/etc/fluent.conf", "-p", "/flue
ntd/plugins", "--under-supervisor"]
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: gem 'fluent-plugin-rewrite-tag-filter' version '2.2.0'
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: gem 'fluent-plugin-sql' version '1.1.1'
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: gem 'fluentd' version '1.6.3'
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: gem 'fluentd' version '1.6.2'
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: adding match pattern="guacamole" type="rewrite_tag_filter"
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: #0 adding rewrite_tag_filter rule: tracker_type [#<Fluent::PluginHelper::RecordAccessor::Accessor:0x00007fa50ae34368 @keys="tracker_type">, /.*/, "", "${tag}.$1"]
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: adding match pattern="guacamole.*" type="sql"
fluentd-g     | 2019-11-15 15:18:49 +0000 [warn]: #0 secondary type should be same with primary one primary="Fluent::Plugin::SQLOutput" secondary="Fluent::Plugin::StdoutOutput"
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: adding source type="forward"
fluentd-g     | 2019-11-15 15:18:49 +0000 [info]: #0 starting fluentd worker pid=14 ppid=6 worker=0
fluentd-g     | 2019-11-15 15:18:53 +0000 [info]: #0 Selecting 'utr_guacamole_connections' table
fluentd-g     | 2019-11-15 15:18:53 +0000 [info]: #0 Selecting 'usr_guacamole_connections' table
fluentd-g     | 2019-11-15 15:18:53 +0000 [info]: #0 listening port port=24224 bind="0.0.0.0"
fluentd-g     | 2019-11-15 15:18:53 +0000 [info]: #0 fluentd worker is now running worker=0
fluentd-g     | 2019-11-15 15:20:32 +0000 [warn]: #0 got unrecoverable error in primary. Skip retry and flush chunk to secondary error_class=NoMethodError error="undefined method `key' for #<Fluent::Plugin::Buffe
r::MemoryChunk:0x00007fa50795d6d0>"
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluent-plugin-sql-1.1.1/lib/fluent/plugin/out_sql.rb:234:in `block (2 levels) in write'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluent-plugin-sql-1.1.1/lib/fluent/plugin/out_sql.rb:233:in `each'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluent-plugin-sql-1.1.1/lib/fluent/plugin/out_sql.rb:233:in `block in write'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluent-plugin-sql-1.1.1/lib/fluent/plugin/out_sql.rb:231:in `write'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluentd-1.6.3/lib/fluent/plugin/output.rb:1128:in `try_flush'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluentd-1.6.3/lib/fluent/plugin/output.rb:1434:in `flush_thread_run'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluentd-1.6.3/lib/fluent/plugin/output.rb:457:in `block (2 levels) in start'
fluentd-g     |   2019-11-15 15:20:32 +0000 [warn]: #0 /usr/local/lib/ruby/gems/2.6.0/gems/fluentd-1.6.3/lib/fluent/plugin_helper/thread.rb:78:in `block in thread_create'

It seems from the documentation that chunk.key doesn't exists and extract_placeholders should be used to extract tag.

So I tried to clone this repository and to install the plugin from sources with this dockerfile:

FROM fluent/fluentd:v1.6.2-debian-1.0
USER root

COPY fluent-plugin-sql/fluent-plugin-sql-1.1.1.gem .

RUN BUILD_DEPS="sudo make gcc g++ libc-dev ruby-dev" \
  && apt-get update \
  && apt-get install -y --no-install-recommends $BUILD_DEPS \
  && apt-get install -y libpq-dev \
  && fluent-gem install fluent-plugin-rewrite-tag-filter \
  && sudo gem install pg \
  && fluent-gem install -g fluent-plugin-sql-1.1.1.gem --no-document \
  && fluent-gem install pg -v 0.21.0 --no-document \
  && sudo gem sources --clear-all \
  && SUDO_FORCE_REMOVE=yes \
    apt-get purge -y --auto-remove \
                  -o APT::AutoRemove::RecommendsImportant=false \
                  $BUILD_DEPS \
  && rm -rf /var/lib/apt/lists/* \
           /home/fluent/.gem/ruby/2.3.0/cache/*.gem

COPY fluent.conf /fluentd/etc/

USER fluent

but I get the following error:

ERROR:  While executing gem ... (NameError)
    undefined local variable or method `metadata' for #<Gem::RequestSet::GemDependencyAPI:0x00007fa5aa439020>

Even if I didn't modified the source code!