I have log files generated from some applications. Some of applications produces messages in following format. So there is "logContent" in message field.
{"instant":{"epochSecond":1628692763,"nanoOfSecond":792000000},"thread":"AWT-EventQueue-0","level":"INFO","loggerName":"com.client.logon.form.Logon","message":"errortype: SECURITY logContent:User Log on user 1","endOfBatch":false,"loggerFqcn":"org.apache.logging.log4j.spi.AbstractLogger","threadId":23,"threadPriority":6,"@timestamp":"2021-08-11T17:39:01.025+0300"}
some of applications produces logs in following format. There is no logContent text in message field
{"@timestamp":"2021-08-16T18:16:23.925+03:00","sequence":3042,"loggerClassName":"org.jboss.logmanager.Logger","loggerName":"stdout","level":"INFO","message":"\t\tCLIENT_UNIQUE_ID:e9d58a5e-67b8-4a11-88b8-71067cea4111","threadName":"EJB default - 1","threadId":357,"mdc":{},"ndc":"","hostName":"evt06001nb","processName":"jboss-modules.jar","processId":18888,"@version":"1"}
I am using Kibana for viewing logs. I want to show a single field in Dashboard. Otherwise it will be complicated for users to look at "logContent" and "message" fields at the same time. So I want to add a check to logstash that if logContent does not have any value , update its value to reflect message field. In discover, I will use "logContent" field.
I implemented following if condition . But it did not work
filter{
json{
source => "message"
}
grok {
match => {
"message" => [
"errortype:%{GREEDYDATA:errorType} logContent:%{GREEDYDATA:logContent}",
"logContent:%{GREEDYDATA:logContent}"
]
}
}
if ![logContent] {
mutate {
update => { "logContent" => "%{[message][message]}" }
}
}
}```