I'm using Zalando Logbook to generate JSON log messages in my Java application. The log messages are configured with a LoggingEventCompositeJsonEncoder in Logback. Now, I want to extract the "custom_field" field from the log message, which is a JSON object, and send it to Logstash.
Here's a snippet of my Logback configuration:
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<!-- Other providers -->
<pattern>
{
"app_name": "${APP_NAME}",
"custom_field": "%message{jsonPath='$.custom_field'}"
}
</pattern>
</providers>
</encoder>
The above example dosn't work. The log messages generated by Zalando Logbook are in JSON format, and I want to extract the "custom_field" field from these messages and include it in the Logstash index.
How can I achieve this? Is there a way to extract the "duration" field from the JSON log message and include it in the Logstash index using the LoggingEventCompositeJsonEncoder pattern configuration?