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>[^:]+):"
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...