Splunk Search

Group Java Exceptions, even though there is no KV pair

seanlon11
Path Finder

I have all types of Java Exceptions within my logs, that have no real form to them, except that they all start with "com." or "java." and end with exactly ".Exception".

For example:

java.lang.IllegalStateException
java.lang.NullPointerException
javax.servlet.ServletException
com.ibm.blah.SomeException
etc.

How can I extract this in-line?

Thanks, Sean

Tags (1)

southeringtonp
Motivator

If you want it purely inline, try:

| rex field=_raw "\b(?<exception_type>(com|java|javax)\.[\w\.]+Exception)"

(Match on either "com" or "java" or javax, followed by a dot, and then as many word characters or dots as you need until you finish with "Exception")

If you'd rather not have to use it in the search string, then:

In transforms.conf:

[exception-type]
REGEX  = \b((com|java|javax)\.[\w\.]+Exception)\b
FORMAT = exception_type::$1

In props.conf:

[yoursourcetype]
REPORT-exceptions = exception-type

Or, you can configure an eventtype for each exception type or group of exception types.

southeringtonp
Motivator

You're right that it was a typo, but the question mark was in the right place. The leading dot should have been a word breaker ('.' vs '\b'). Edited above to correct.

0 Karma

tedder
Communicator

I think you have a simple typo. Taking part of your query:
".(?(com|java).[\w.]+Exception)"
try this:
".(<?exception_type>(com|java).[\w.]+Exception)"

0 Karma

seanlon11
Path Finder

How do I then reference these fields? I tried the following, but it did not work.

eventtype="all_web" *Exception | rex field=_raw ".(?(com|java).[\w.]+Exception)" | stats count(exception_type) by host

Thanks for the help!

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...