Logstash issue with json input from beats [Solved]

I have solved it now. I renamed the message field to msg.

solution below.

logback.xml (logback xml file in spring boot application)

<appender name="stash" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
        <level>info</level>
    </filter>
    <file>/home/rob/projects/scratch/log-tracing-demo/build/logs/tracing-A.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>/home/rob/projects/scratch/log-tracing-demo/build/logs/tracing-A.log.%d{yyyy-MM-dd}</fileNamePattern>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder class="net.logstash.logback.encoder.LogstashEncoder" >
        <includeContext>false</includeContext>
        <fieldNames>
            <message>msg</message>
        </fieldNames>
    </encoder>
</appender>

So now the json-file examples look like the following.
{"@timestamp":"2017-09-11T14:32:47.920+01:00","@version":1,"msg":"Unregistering JMX-exposed beans","logger_name":"org.springframework.jmx.export.annotation.AnnotationMBeanExporter","thread_name":"Thread-19","level":"INFO","level_value":20000}

Then in the logstash added the following filter

filter {
  mutate {
    rename => {"msg" => "message"}
  }
}
1 Like