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!

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...