I am using the redhat openshift logging operator provided fluentd forward to forward my logs to a Logstash instance, and using the azure log analytics output plugin to forward the logs to an Azure Log Analytics Workspace.
I am seeing the following Warning continuously in my Logstash logs:
May 18 09:48:53 cbxrelaysrvsit1 logstash[39503]: [2022-05-18T09:48:53,219][WARN ][logstash.outputs.azureloganalytics][main][43328c4a9749fe314828ca147d3b05e72c47d0cd340a51d239257c16fca6eac1] Failed to flush outgoing items {:outgoing_count=>1, :exception=>"JSON::GeneratorError", :backtrace=>["json/ext/GeneratorMethods.java:79:in `to_json'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/microsoft-logstash-output-azure-loganalytics-1.0.0/lib/logstash/logAnalyticsClient/logStashAutoResizeBuffer.rb:41:in `flush'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/buffer.rb:219:in `block in buffer_flush'", "org/jruby/RubyHash.java:1415:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/buffer.rb:216:in `buffer_flush'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/buffer.rb:159:in `buffer_receive'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/microsoft-logstash-output-azure-loganalytics-1.0.0/lib/logstash/logAnalyticsClient/logStashAutoResizeBuffer.rb:28:in `add_event_document'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/microsoft-logstash-output-azure-loganalytics-1.0.0/lib/logstash/outputs/microsoft-logstash-output-azure-loganalytics.rb:85:in `block in multi_receive'", "org/jruby/RubyArray.java:1809:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/microsoft-logstash-output-azure-loganalytics-1.0.0/lib/logstash/outputs/microsoft-logstash-output-azure-loganalytics.rb:78:in `multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:143:in `multi_receive'", "org/logstash/config/ir/compiler/AbstractOutputDelegatorExt.java:121:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:295:in `block in start_workers'"]}
I am also using Filebeat in some other VMs, and am able to aggregate those logs to Azure Log Analytics, but facing this issue after using fluent input.
The following is my Logstash pipeline.conf:
The to_json is finding something in the message that it does not know how to encode. JSON is unicode. If your message has some other character encoding then it may contain characters (or NaN) that are not valid Unicode, in which case this exception will occur.
You need to find out what encoding the source of your events is using. You can force the encoding to UTF-8 in a ruby filter once you know that. This may help you understand the problem.
Thank you very much for that reply. I think you've pushed me in the right direction. I will check the encoding of my logs.
I have 3 questions from your response:
From the solution in stackoverflow link, I would need to identify the corresponding for ISO-8859-1 that I am using in my logs, correct?
@Badger I am also seeing this in the start up of my Logstash logs:
[2022-05-19T09:53:32,292][ERROR][logstash.codecs.fluent ][main][4fe2598517a75ecc0668a0a6e7a9f6e9c056628fcac106ac2ef5213729b2555f] Fluent parse error, original data now in message field {:error=>#<NoMethodError: undefined method `merge' for 1:Integer>, :data=>102}
[2022-05-19T09:53:32,303][ERROR][logstash.codecs.fluent ][main][4fe2598517a75ecc0668a0a6e7a9f6e9c056628fcac106ac2ef5213729b2555f] Fluent parse error, original data now in message field {:error=>#<TypeError: can't convert nil into an exact number>, :data=>"pod_ip"}
[2022-05-19T09:53:32,309][ERROR][logstash.codecs.fluent ][main][4fe2598517a75ecc0668a0a6e7a9f6e9c056628fcac106ac2ef5213729b2555f] Fluent parse error, original data now in message field {:error=>#<TypeError: can't convert nil into an exact number>, :data=>"host"}
Are these the characters that are causing me trouble?
I saw this GIT post that said to remove the codec = fluent from my logstash inputs. When I did that change, I am able to receive the logs, but it has all the metadata that fluent sends in the Message field itself.
Attaching my logstash inputs section:
input {
beats {
port => "5044"
}
tcp {
port => 4000
}
}
I am sending this the log to Azure Log Analytics workspace output. I am seeing the Fluentd's metadata as well in the Message itself. I have highlighted the actual message in the below log snippet.
A sample log message that I received that was previously throwing the parse error:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.