i have logs in the following format
{
"timeMillis" : 1590564813191,
"thread" : "JOBSCHEDULER_THREAD_2",
"level" : "ALERT",
"loggerName" : "JobScheduler",
"message" : "value1*value2*value3*value4*",
"endOfBatch" : false,
"loggerFqcn" : "org.apache.logging.log4j.spi.AbstractLogger",
"threadId" : 18,
"threadPriority" : 5
}
i was able to parse the JSON fields using below pattern i.e. entire value in "message" in JSON is mapped to a field called "message" and shown in Kibana.
json {
source => "message"
}
date {
timezone => "UTC"
match => ["timeMillis", "UNIX_MS"]
target => "@timestamp"
}
However i am trying to parse the values with in the field "message" which are delimited by '*'. i want to get each value in to a different field (fields are pre-defined as the pattern is constant ).
i have tried different ways but not succeeded. please help me.
You could use mutate+split to turn the message field into an array of 4 strings, but if you want them to be top-level fields then what do you want them to be called?
Thanks Chitresh. i will try the approach you suggested. but infact the field names field1, field2 etc.. are not exact i just gave some dummy names..so they are not in the same pattern to use "field#{i+1}". field names are "alertid', "kpiobserved", "kpithreshold", "version".
Thank you so much. it is working now. but only one issue here... for the message[0] it is actually parsing the entire message till first '*' (as pasted below ) but not the first value1 in the JSON field message. seems like its interpreting message with entire JSON message not just the field message
i am assuming it can be fixed by match filter. will try that
You have already parsed the JSON with a json filter, so [message] is no longer JSON and that parse will throw an exception. Replace those two lines with
Thanks. But that is what i tried yesterday based on your previous post. if i just use "
kpis = event.get("message").split("*")" then the entire JSON till the first '*' including values from other fields as below is set to message[0] which is an issue.
In one case you are parsing the JSON twice (so it fails because "2020-05-27 07:33:49,136 GMT8PEGA000510855..." is not a valid JSON object), in other case you are not parsing it at all. You need to parse it once.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.