echo ‘{“message”:“hello”}’ | fluent-cat debug.log
generates output:
wrong number of arguments (1 for 0)
Please help to understand the issue. Many thanks.
echo ‘{“message”:“hello”}’ | fluent-cat debug.log
generates output:
wrong number of arguments (1 for 0)
Please help to understand the issue. Many thanks.
I just tried the same example you are trying to do, as described in fluend’s README file:
gem install fluentd
fluentd -s conf
fluentd -c conf/fluent.conf &
echo '{"json":"message"}' | fluent-cat debug.test
And it just worked well.
What version of it have you installed?
I have 1.14.4
:
fluentd --version
fluentd 1.14.4
ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
Thank you… This is what we have:
fluentd 0.12.43
ruby 2.0.0p598 (2014-11-13 revision 48408) [i386-solaris2.10]
Perhaps it is yajl-ruby issue?
2022-01-13 11:01:20 -0500 [warn]: fluent/root_agent.rb:187:emit_error_event: dump an error event: error_class=ArgumentError error=“wrong number of arguments (1 for 0)” location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’" tag=“fluent.warn” time=1642088924 record={“error_class”=>“ArgumentError”, “error”=>“wrong number of arguments (1 for 0)”,
I installed that version of Ruby
and fluentd
, and the example worked fine (I do receive another kind of error, but the message is received well).
The yajl-ruby
version is the same (1.4.1
).
The error you are showing me says the problem is in line 80. The line 80 of my yajl.rb
file is:
new(options).encode(obj, io, &block)
Both new
and encode
receive more than 0
arguments.
What is the content of the line 80 of the yajl
file you have installed in your system?:
sed -n '80p' /opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb
Another thing I noticed, was that the configuration files created by the new fluentd and the old one are technically identical (they differ in some comments).
Make sure you are using a clean config file. I’m using this one.
new(options).encode(obj, io, &block)
Also, perhaps something wrong is here in “initialize”?
class Projector
def initialize(stream, read_bufsize=4096)
@stream = stream
@buffer_size = read_bufsize
end
end
(80:in `initialize’" tag=“fluent.warn” time=16420
88924 record={“error_class”=>“ArgumentError”, “error”=>“wrong number of arguments (1 for 0)”,)
I don’t understand Ruby at all… but from a common logic I have replaced:
==========================
** class Projector**
** def initialize(stream, read_bufsize=4096)**
** @stream = stream**
** @buffer_size = read_bufsize**
** end**
** end**
====================
by **
======================
** class Projector
** def initialize(stream)**
** @stream = stream**
** @buffer_size = 4096**
** end**
** end**
=============
What do you think? Thank you.
Please find my replies below. Many thanks for your time!
I wouldn’t modify the installed gems, over all because obviously you are working with a really old system with unsupported components (i.e. Ruby 2.0). At least, try to make a backup of whatever you are changing before proceeding.
In particular, that change is not necessary because read_bufsize
is an optional parameter, so calling initialize
with 1 or 2 parameters is valid. Calling it with 1 parameter, will assign 4096
to read_bufsize
by default.
I would double check the configuration file.
I wanted to encourage you to upgrade your system, but I know it will be tough (is it really a Solaris 2.10 running on a 32 bits architecture?).
Something you could do is to install byebug
and prepend the word byebug
in the file /opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb
, maybe in the line 80
which will effectively add a breackpoint there and then debug. Or you can do a discarding process placing the brackpoints in that file at different sensible places until you catch the execution control in the debugger. Ideally you could locate in the line just before the exception raises, and then you can see what is happening.
I’m trying to use @type tail as a
2022-01-13 23:12:24 -0500 [warn]: fluent/root_agent.rb:187:emit_error_event: dump an error event: error_class=ArgumentError error=“wrong number of arguments (1 for 0)” location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in initialize'" tag="fluent.warn" time=1642133477 record={"error_class"=>"ArgumentError", "error"=>"wrong number of arguments (1 for 0)", "location"=>"/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in
initialize’", “tag”=>“fluent.warn”, “time”=>1642133476, “record”=>{“timestamp”=>"[2022-01-13", “@timestamp”=>“2022-01-13T23:11:16-05:00”, “tag”=>“collectd.messages”}, “message”=>“dump an error event: error_class=ArgumentError error=“wrong number of arguments (1 for 0)” location=”/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’" tag=“collectd.messages” time=1642133476 record={“timestamp”=>"[2022-01-13", “@timestamp”=>“2022-01-13T23:11:16-05:00”, “tag”=>“collectd.messages”}", “@timestamp”=>“2022-01-13T23:11:17-05:00”}
We have tried to install newer versions of Ruby and Fluentd many times with no success. Currently this is the only configuration which is started and running on Solaris 10.
Can we ask… do you see following string in yajl.rb
require ‘yajl/yajl’
?
libruby2.0.so.2 => /opt/csw/lib/libruby2.0.so.2
libpthread.so.1 => /lib/libpthread.so.1
librt.so.1 => /lib/librt.so.1
libsocket.so.1 => /lib/libsocket.so.1
libdl.so.1 => /lib/libdl.so.1
libcrypt_d.so.1 => /usr/lib/libcrypt_d.so.1
libm.so.2 => /lib/libm.so.2
libc.so.1 => /lib/libc.so.1
libaio.so.1 => /lib/libaio.so.1
libmd.so.1 => /lib/libmd.so.1
libnsl.so.1 => /lib/libnsl.so.1
libgen.so.1 => /lib/libgen.so.1
libmp.so.2 => /lib/libmp.so.2
libscf.so.1 => /lib/libscf.so.1
libdoor.so.1 => /lib/libdoor.so.1
libuutil.so.1 => /lib/libuutil.so.1
symbol not found: main (/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl/yajl.so)
symbol not found: isinf (/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl/yajl.so)
Please clarify - can we trust this code in yajl-ruby gem yajl.rb file? (# TODO: this code smells, any ideas?)
class Encoder
def self.encode(obj, *args, &block)
# TODO: this code smells, any ideas?
args.flatten!
options = {}
io = nil
args.each do |arg|
if arg.is_a?(Hash)
options = arg
elsif arg.respond_to?(:write)
io = arg
end
end if args.any?
new(options).encode(obj, io, &block)
end
end
end
========= it generates following error:
2022-01-21 12:26:09 -0500 [warn]: fluent/root_agent.rb:187:emit_error_event: dump an error event: error_class=ArgumentError error=“wrong number of arguments (1 for 0)” location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in initialize'" tag="fluent.warn" time=1642785969 record={"error_class"=>"ArgumentError", "error"=>"wrong number of arguments (1 for 0)", "location"=>"/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in
initialize’", “tag”=>“fluent.debug”, “time”=>1642785969, “record”=>{“message”=>“fluentd main process get SIGINT”, “@timestamp”=>“2022-01-21T12:26:09-05:00”}, “message”=>“dump an error event: error_class=ArgumentError error=“wrong number of arguments (1 for 0)” location=”/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize’" tag=“fluent.debug” time=1642785969 record={“message”=>“fluentd main process get SIGINT”, “@timestamp”=>“2022-01-21T12:26:09-05:00”}", “@timestamp”=>“2022-01-21T12:26:09-05:00”}
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs