Open gadiego92 opened 10 months ago
Thanks for your report! Obviously the documentation is wrong.
encoding
parameter is set, in_tail tries to convert input string from ASCII-8BIT
to encoding
ASCII-8BIT
to UTF-8
before converting it to encoding
.What do you mean when you say the following ?
- Ruby tries to convert the original string from
ASCII-8BIT
toUTF-8
before converting it toencoding
.
Do you mean there are two encoding process ?
If I'm not wrong by default both from_encoding
and encoding
value is ASCII-8BIT
. So by default the encode
function is not called.
Describe the bug
The Official Documentation states regarding the encoding for the tail plugin:
_source: tail#encoding-from_encoding_
I have been checking Fluentd source code and:
Regarding the first bullet. I think
encoding
parameter is not being used as it states in the Documentation. I cannot find the functionString#force_encoding
using theencoding
parameter. On the other side I have found theString#force_encoding
function with thefrom_encoding
parameter in few places. I think line 992 might be wrong: https://github.com/fluent/fluentd/blob/74db9477f445ef83384eca6da8d6c2049945d8cd/lib/fluent/plugin/in_tail.rb#L992 If the Documentation is not wrong the functionString#force_encoding
should use theencoding
value not thefrom_encoding
value.Regarding the second bullet. It states the
String#encode
function is used whenfrom _encoding
parameter is set but it seemsString#encode
is used by default is you setencoding
parameter to something different thanASCII-8BIT
becausefrom_encoding
is set by default toASCII-8BIT
. For example,String#encode
is used if you setencoding
parameter toUTF-8
but according to the DocumentationString#force_encoding
should be used when you set theencoding
parameter and notString#encode
.To Reproduce
Just start a Fluentd container with GROK plugin.
Then run the command:
Expected behavior
Your Environment
Your Configuration
Your Error Log
Additional details
If I set both encoding parameters to UTF-8 I get a warning on the Fluentd logs but the special characters are represented. I don't know if this is the proper way to represent the special characters since I get a warning. Shouldn't this warning be change to info ?
Configuration
Warning
Output
Documentation not clear or wrong
Another option could be that Fluentd works as expected but the Documentation is not clear enough or it's wrong.