Splunk Search

Need to extract JSESSIONID from result

rh417692
Path Finder

Query: index="prod" "Null Pointer Exception"
Result: Key: value, key; value, JSESSIONID:123456.ATG.PROD, key: value

How do I extract only the JSESSIONID from the result?

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this

index="prod" "Null Pointer Exception" | rex "JSESSIONID\:(?<JSESSIONID>[^\.]+)"

View solution in original post

somesoni2
Revered Legend

Try this

index="prod" "Null Pointer Exception" | rex "JSESSIONID\:(?<JSESSIONID>[^\.]+)"

rh417692
Path Finder

Is there a way to capture unique JSESSIONID values?

0 Karma

somesoni2
Revered Legend

Do you mean your search result should show one event per JSESSIONID? If yes, then use like this

index="prod" "Null Pointer Exception" | rex "JSESSIONID\:(?<JSESSIONID>[^\.]+)" | dedup JSESSIONID
0 Karma

rh417692
Path Finder

The 'dedup JSESSIONID' got me unique JSESSIONID values. Thank you @somesoni2 !

0 Karma

rh417692
Path Finder

Do you mind explaining this part please: "JSESSIONID:(?[^.]+)" ? Does it mean to capture the value after the colon? If yes, and if there was a space after colon, would it have captured that too? How would you ignore the space after the colon?

0 Karma

somesoni2
Revered Legend

It's basically everything between JSESSIONID: and first occurance of dot. It would capture that space as well. To ignore that try this. This will ignore space if present after colon (0 or more occurance of space)

| rex "JSESSIONID\:\s*(?<JSESSIONID>[^\.]+)"
Get Updates on the Splunk Community!

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 ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...