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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

Data Management Digest – May 2026

Welcome to the May 2026 edition of Data Management Digest!   As your trusted partner in data innovation, the ...