Cannot use the null byte (\0) as delimiter in tcp input plugin.
-
fluentd or td-agent version. fluentd v0.12.29
-
Environment information, e.g. OS. macOS sierra + docker (dockerized fluentd using alpine linux) But I figure this issue does not matter with environment.
-
Your configuration
<source>
@type tcp
tag log
keep_time_key true
delimiter "\0"
port 5170
bind 0.0.0.0
format none
</source>
The important part in my configuration is delimiter. I just wanted to use the null byte ("\0" in ruby) as my delimter of tcp input.
- Your problem explanation. If you have an error logs, write it together.
Error logs
/opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/basic_parser.rb:92:in `parse_error!': unexpected back-slash escape character '0' at fluentd.conf line 18,15 (Fluent::ConfigParseError)
17: keep_time_key true
18: delimiter "\0"
---------------^
19: port 5170
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:185:in `eval_escape_char'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:90:in `scan_double_quoted_string'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:71:in `scan_string'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:64:in `parse_literal'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:130:in `parse_element'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:95:in `parse_element'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:43:in `parse!'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:33:in `parse'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config.rb:30:in `parse'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/supervisor.rb:480:in `read_config'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/supervisor.rb:144:in `start'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/command/fluentd.rb:173:in `<top (required)>'
from /opt/ruby/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/ruby/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/bin/fluentd:5:in `<top (required)>'
from /opt/ruby/bin/fluentd:22:in `load'
from /opt/ruby/bin/fluentd:22:in `<main>'
I figure this is because fluentd does not accept the null byte expression when it tries to parse its configurations. There is code like below in lib/fluentd/config/literal_parser.rb.
def eval_escape_char(c)
case c
when '"'
'"'
when "'"
"'"
when "r"
"\r"
when "n"
"\n"
when "t"
"\t"
when "f"
"\f"
when "b"
"\b"
when /[a-zA-Z0-9]/
parse_error! "unexpected back-slash escape character '#{c}'"
else # symbols
c
end
end
The null byte expression ("\0") is declined by the regex /[a-zA-Z0-9]/. Is this intented? Is there way to use the null byte as delimiter of tcp input plugin?
It's just missed, and looks good to add. @repeatedly how do you think about this?
It seems good.