Splunk Search

whats the rex command to filter the special characters and extract only required fields?

guru89044
Explorer

Hello experts,

logs looks something like this..

(java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException:...

null\n\njava.lang.IllegalArgumentException
: java.util.concurrent.ExecutionException..
( java.util.concurrent.ExecutionException)
" java.util.concurrent.ExecutionException"

query should ignore the special characters before java and take only exception.

example: query should find "java.lang.IllegalArgumentException" from this log line "null\n\njava.lang.IllegalArgumentException".

I am able to pull exceptions which are not associated with special characters using rex "(?java?.[.\w]+Exception)" but

thanks

Tags (1)
0 Karma

mayurr98
Super Champion

can you please provide full sample events and output you want?

0 Karma

bangalorep
Communicator

Hello!
Try this run anywhere search

| makeresults 
| eval _raw="null\n\njava.lang.IllegalArgumentException
: java.util.concurrent.ExecutionException..
( java.util.concurrent.ExecutionException)
\" java.util.concurrent.ExecutionException\"" 
| rex field=_raw max_match=0 "(?<javaexception>java?.[.\w]+Exception)"

You can try something like this

| rex field=_raw (?<javaexception>java?.[.\w]+Exception)

OR

| rex field=_raw (?<javaexception>java.*Exception)
0 Karma

guru89044
Explorer

ddint work. its not correct.

0 Karma

bangalorep
Communicator

I edited my answer. did you check?
Also, if its not correct can you elaborate by giving sample inputs and what output you want

0 Karma

bangalorep
Communicator

Try this run anywhere search

| makeresults 
| eval _raw="null\n\njava.lang.IllegalArgumentException
: java.util.concurrent.ExecutionException..
( java.util.concurrent.ExecutionException)
\" java.util.concurrent.ExecutionException\"" 
| rex field=_raw max_match=0 "(?<java>(\S+|)java.\w+.*Exception)"
0 Karma

guru89044
Explorer

no rex command is still not working.

0 Karma

bangalorep
Communicator

Can you please send me one full event? Also, please send the search query you're using.

0 Karma

guru89044
Explorer
0 Karma

bangalorep
Communicator

For this, you need to use max_match=0 in the rex expression.

Use this query

rex field=_raw max_match=0 "(?<java>(\S+|)java.\w+.*Exception)"
0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...