Splunk Search

rex extract first string

indeed_2000
Motivator

Hi

How can I extract first occured this "User ABC123 invalid"  with rex?

Here is the log:

2021-10-03 13:26:44,441 ERROR [APP] User ABC123 invalid: javax.security.auth.login.LoginException: User ABC123 invalid

 

Thanks,

Labels (6)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\]\s(?<error>[^:]+):"

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @indeed_2000,

if your want to extract the message after "LoginException", you could use the following regex:

| rex "LoginException:\s+(?<message>.*)"

that you can test at https://regex101.com/r/Gz7glo/1

Ciao.

Giuseppe

ITWhisperer
SplunkTrust
SplunkTrust

Doesn't this give the second occurrence not the first?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\]\s(?<error>[^:]+):"
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Mile High Learning with Splunk University, Denver, Colorado

If Denver is known for its mile-high elevation, Splunk University is about to raise the bar on technical ...

IT Service Intelligence 5.0 Series: Your Guide to the June Launch

We are excited to announce the June release of Splunk IT Service Intelligence (ITSI) 5.0. This update ...

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...