Hi,
I am trying to show successful validations and failures in one of the dashboard panels. I am logging exceptions in traceData.exception field. In this field there is exception with full stacktrace , but would like to display just exception name so need to extract just first line of exception.
My query looks like
index=xxx sourcetype="xxx" app=xxx event.data.request.uri="/xxx"
| rename event.data.response.statusCode as statusCode
| rename event.traceData.exception as exception
| rex field=exception "(?<exception>.*)"
| eval result = if(statusCode=201,"Valid", 'exception')
| timechart span=1h count by result
2022-10-13 08:00 | 1 | 1 | 1 |
I have actually found a solution. I found this post fields appearing as null when too long , my exceptions are quite long so it sounded like this is the case with my events, and using solution from there I made my query working.
index=xxx sourcetype="xxx" app=xxx event.data.request.uri="xxx"
| rename event.data.response.statusCode as statusCode
| spath input=_raw path=event.traceData.exception output=exception
| rex field=exception "(?<exception>.*)"
| eval result = if(statusCode=201,"Valid", exception)
| timechart span=1h count by result
Thank you @richgalloway for your time
Please share sanitized samples of validations and failures. We can't check your regular expression without it.
Here are samples of success and failures
Thanks for the sample events. Which exception is displayed and which one is not?
The rex command in the query seems meaningless. It looks at the exception field and puts everything it finds into the exception field. Why?
Thank you for trying to help.
It displays second exception and success response. The other one displays as null, but query finds all the events.
Rex I found in someone else's question how to display exception without stacktrace, within all the proposed solution, that was the only one actually working. Without this 'rex' it displays exception with stacktrace.
I have also noticed strange thing about those exceptions not displaying (displaying as NULL). When I search for the events, and in my query use add event.traceData.exception!=NULL or event.traceData.exception=* it does not find them. Also when I click on the exception field and try to add it to a search or exclude it from search it does not do anything. What could cause that ? In the code all those exceptions are logged the same way, the only difference between them is the type of exception. But that really should not matter as I should be able to add to the field whatever I want ...
I have actually found a solution. I found this post fields appearing as null when too long , my exceptions are quite long so it sounded like this is the case with my events, and using solution from there I made my query working.
index=xxx sourcetype="xxx" app=xxx event.data.request.uri="xxx"
| rename event.data.response.statusCode as statusCode
| spath input=_raw path=event.traceData.exception output=exception
| rex field=exception "(?<exception>.*)"
| eval result = if(statusCode=201,"Valid", exception)
| timechart span=1h count by result
Thank you @richgalloway for your time