Splunk Search

another rex question

packet_hunter
Contributor

Scenario, I have a field (msg) below and I need to extract the user id which is user = [abcdefg]

field msg = AAA user accounting Successful : server = 192.168.0.1 : user = abcdefg

index = main | rex field=msg [?] ....

I need the abcdefg portion.
Thank you!

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Assuming the value is terminated by a space, this should do the job.

... | rex field=msg "user = (?<user>[^ ]*)" | ...
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Assuming the value is terminated by a space, this should do the job.

... | rex field=msg "user = (?<user>[^ ]*)" | ...
---
If this reply helps you, Karma would be appreciated.

packet_hunter
Contributor

only getting a single character under stats list(user)

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I forgot the quantifier (*). Try the updated answer.

---
If this reply helps you, Karma would be appreciated.
0 Karma

packet_hunter
Contributor

Thank you, will have to test later, someone just restarted my indexer....

0 Karma

packet_hunter
Contributor

Sweet!!!! it works great! Thank you

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...