Hi all,
First post on this forum, so hi all ! And long life to elastic !
I'm here cause I need some advice about GELF and log4j.
As for now, we used "log4j" input to receive data from app using log4j 1.2 with MDC.
As we want to upgrade the elk to latest version, log4j input plugin is now deprecated, and no log are parse by the plugin.
As we can't use filebeat cause it don't manage the MDC fields (and don't want more disk io), we try gelf.
It works, but I think we lost logs.
Here the config:
INPUT:
input {
gelf {
host => "10.x.x.x"
type => "java_app"
port_tcp => "4560"
use_tcp => "true"
use_udp => "false"
}
}
OUTPUT:
output {
if [type] == "java_app" {
elasticsearch {
index => "java_app-%{+YYYY.MM.dd}"
hosts => [ "host1","host2" ]
manage_template => false
}
}
}
No filter for now, I just try to be more simple as possible for the test.
And the last, is the log4j appender:
<appender name="SOCKET" class="biz.paluch.logging.gelf.log4j.GelfLogAppender"> <param name="Threshold" value="DEBUG" /> <param name="Host" value="tcp:logstash.hostname" /> <param name="Port" value="4560" /> <param name="ExtractStackTrace" value="true" /> <param name="FilterStackTrace" value="true" /> <param name="TimestampPattern" value="yyyy-MM-dd HH:mm:ss,SSS" /> <param name="MaximumMessageSize" value="32768" /> <param name="IncludeFullMdc" value="true" /> <param name="additionalFields" value="application=${applicationName}" /> <param name="additionalFieldTypes" value="application=String" /> <GelfLayout compressionType="GZIP" compressionThreshold="1" /> </appender>
As I say, everything works , I see logs parse by logstash and available in Kibana, but I get many warn logs like this in logstash:
[2018-02-22T20:42:12,196][WARN ][logstash.inputs.gelf ] Gelf (tcp): failed to parse a message. Skipping: eventIdt {:exception=>#<JSON::ParserError: unexpected token at 'eventIdt'>, :backtrace=>["json/ext/Parser.java:250:in
parse'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/json-1.8.6-java/lib/json/common.rb:155:in
parse'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-gelf-3.1.0/lib/logstash/inputs/gelf.rb:155:intcp_listener'"]}
And I don't why and how to solve that !
I try to set the codec to "json" in the input, with no success.
Somebody have an idea why ?
I take advice or other experience too if there a better way to send directly logs from app using log4j 1.2 to logstash.
Thanks for your help !
Mouglou