I am trying to write a ELK-Watcher to send alert in case of any exception in my Java-Application logs.
Our application-log is already getting indexed in Elastic-Search. And under log_message field, I am able to index log-message or exception-message(in case of exception) along with exception-trace.
For example
In normal case(with no exception) log_message field will have value something like as follows.
Executing task using ExecutorService
But in case of Exception, log_message field have something like as follows
Exception while executing task : java.util.concurrent.CancellationException [StackTrace Hash 38fe72fbd18c26e8cd74b0a3c196c1441f1814e10224a323f83ec105dd355f10]
java.util.concurrent.CancellationException
at java.util.concurrent.FutureTask.report(FutureTask.java:121)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at com.comp.tasks.TaskExecutor$MDCFuture.get(TaskExecutor.java:103)
at com.comp.tasks.TaskExecutor.afterExecute(TaskExecutor.java:239)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Above two are just sample log_message's, but exception can originate from any other class in application with different exception-message or exception-trace.
I want to write ELK-Watcher and use Kibana-filter-query-DSL to detect if log_message field contains exceptions.
I tried many different Kibana-filter-query-dsl to filter-out log_message with exception trace. But none of them worked.
Is it possible to write any Kibana-filter-query-dsl to detect exception by looking for \n\tat in log_message field? Please help.
log.levelfield from your application log ? If you are storing then it will be very easy because then you need to just check iflog.levelvalue iserrorand send alert.StackTraceorat java.lang.Thread.runwhich will be available for all your stacktrace. You might get some unexpected result but most of scenario it will cover.wildcardquery with prefix and postfix*thats why it is taking long time. Insted of this trymatch_phrasequery.