I have logback.groovy that sends data to logstash on the network with some custom fields:
appender("LOGSTASH", LogstashTcpSocketAppender) { encoder(LogstashEncoder) { customFields = """{ "token": "xxxxx", "environment":"dev", "some_property":"foobar" }""" } remoteHost = "logstashlistener.host.name" port = 5000 }
So far so good. However, I need to clear some field names that are not valid for elasticsearch downstream. Based on the LogstashEncoder documentation, this can be achieved as follows:
<encoder class="net.logstash.logback.encoder.LogstashEncoder"> <fieldNames> <timestamp>time</timestamp> <message>msg</message> ... </fieldNames> </encoder>
This seems wonderful, but I have to put this in the logback.groovy notation. I tried as hashmap, string and more, but always ended with Cannot cast object 'xxxx' with class 'xxxx' to class 'net.logstash.logback.fieldnames.LogstashFieldNames'
groovy logstash
Eric Darchis
source share