Splunk Search

How to extract repeated field values in same event?

rajs115
Path Finder
Hi Guys, I am new to splunk. I need to run a query to extract the system name value which is repeated twice in the same log event. Logs in one event are: user: user1 system: system1 user:user2 system: system2 output should look like below: output1 output2 system1 system2 cheers.
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=2 "system:\s(?<system>[\S]+)"
| eval system1=mvindex(system,0)
| eval system2=mvindex(system,1)

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=2 "system:\s(?<system>[\S]+)"
| eval system1=mvindex(system,0)
| eval system2=mvindex(system,1)

rajs115
Path Finder

@ITWhisperer ,

 

Logs in one event are:

user: user1

system: system1

 

user:user2

system: system2

 

output should look like below:

output1      output2

system1     system2

 

I tried as you suggested. Not returning any values.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you share the raw events in a code block </>

0 Karma

rajs115
Path Finder

@ITWhisperer ,

  Its working now. Made a slight change from your command. Not sure it its appropriate or not. is there any way we can compare these two values  or same or not (if system1=system2) 

 

| rex max_match=2 "system:\s(?<system>[\S]+)"
| eval system1=mvindex(system,-1)
| eval system2=mvindex(system,0)

 

0 Karma

rajs115
Path Finder
Logs in one event are: user: user1 system: system1 user:user2 system: system2 output should look like below: output1 output2 system1 system2
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...