INFO >2016-12-20 04:03:58,123 com.pkg.test.controller.JavaClassName[abc-0123-123]: Some text. Time taken:17
INFO >2016-12-20 04:04:19,123 com.pkg.test.controller.JavaClassName[art-9999-321]: ClassName(-,-) -> Some text; time taken:1
INFO >2016-12-20 04:04:53,123 com.pkg.test.controller.JavaClassName[uyt-8888-888]: someFunction (list): Completed. Time taken:2ms
I have multiple log patterns and it changes for different scenarios, so i can't write multiple patterns in my conf file. I have written the below grok pattern for my logs :
Now i want to find out the time taken by a particular class and create a graph for it. But the challenge is, i don't have an "Time taken" field and i have different "Time taken" text in my logs :
a) Time taken:17, with capital "T".
b) time taken:1, with small "t".
c) Time taken:2ms, with capital "T" and "ms" appended with it.
I want to find out all the classes whose time taken is greater than 5ms.
Thanks for the response
The above grok filter worked.
Yes, all the Time taken values are in "ms" even if is not appended.
Now I got another pattern for which I have written multiple grok pattern, but only one of the filter works which comes first and other fails. How this thing can be resolved?
INFO >2016-12-27 08:00:38,006 com.pkg.test.controller.JavaClassName[abc-0553-123]: Some text.
INFO >2016-12-20 04:03:58,123 com.pkg.test.controller.JavaClassName[abc-0123-123]: Some text. Time taken:17
INFO >2016-12-20 04:04:19,123 com.pkg.test.controller.JavaClassName[art-9999-321]: ClassName(-,-) -> Some text; time taken:1
INFO >2016-12-20 04:04:53,123 com.pkg.test.controller.JavaClassName[uyt-8888-888]: someFunction (list): Completed. Time taken:2ms
If I'm understanding the situation correctly, the lines are matching on the first filter when you want it to match on the second filter (the one with [Tt]ime [Tt]aken). I suspect because the first one still matches the line so it never tries the second? If you put the more specific filter first, does it change the outcome?
You can also probably do this with one match line by making the last part options by changing it to (?:[Tt]ime taken:%{NUMBER:TIME_TAKEN}|). Though I seem to be having a problem matching the message that way, without using greedy data.
This one might work: %{LOGLEVEL:severity}%{SPACE}>%{TIMESTAMP_ISO8601:timestamp} %{JAVACLASS:class}\[%{DATA:threadname}\]: (?:%{DATA:message}[Tt]ime taken:%{NUMBER:TIME_TAKEN}|%{GREEDYDATA:message})
By the way, you will probably get better help asking these questions in the logstash channel - there are people more versed in grok filters than I in there.
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.