Splunk Search

How to correlate to multi-value fields from one event?

gnostic_device
Engager

Hello, 

I have logs where there are multiple values for two fields. This data looks like this example below for each event.

dest user builtinadmin
computer1 user1
user2

true

false

     

 

It comes from this raw data:

<computer N=computer1 D=corp OS=Windows DC=false>
<users>
<user N='user1" builtinadmin="false" />
<user N="user2" builtinadmin="true" />
</users>
</computer>

 

Is there a way to show the data like this instead where each user correctly correlates to the builinadmin value?

dest user builtinadmin
computer1 user1 true
computer1 user2 false
Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Since your data is in XML, here is an alternative to mvzip-split combination, using path option in builtin function spath.

 

| rename computer{@N} AS dest ``` you already did this in your original search ```
| spath path=computer.users output=users ``` retain complete path as a single XML field ```
| eval users = split(users, "
") ``` for some reason users is single string; turn into multivalue ```
| mvexpand users
| spath input=users ``` extract user attrib from XML after mvexpand ```
| rename user{@N} as user, user{@builtinadmin} as builtinadmin ``` do this AFTER mvexpand, not before ```
| table dest user builtinadmin

 

Sample data gives

destuserbuiltinadmin
computer1user1false
computer1user2true
Tags (1)
0 Karma

mayurr98
Super Champion

Hey

Not sure if there is any other easy way to do this but you can give this a try:

<user search>
|eval tagged=mvzip(user,builtinadmin) 
| mvexpand tagged 
| makemv tagged delim="," 
| eval user=mvindex(tagged,0) 
| eval builtinadmin=mvindex(tagged,1) 
| table dest user builtinadmin

let me know if this helps!

kamlesh_vaghela
SplunkTrust
SplunkTrust

@gnostic_device 

Can you please try this?

 

YOUR_SEARCH
| eval t=mvzip(user,builtinadmin,"|")
| mvexpand t
| eval user=mvindex(split(t,"|"),0),builtinadmin=mvindex(split(t,"|"),1)  | table dest	user	builtinadmin

 

 

My Sample Search :

 

| makeresults | eval _raw="<computer N=computer1 D=corp OS=Windows DC=false><users><user N=\"user1\" builtinadmin=\"false\" /><user N=\"user2\" builtinadmin=\"true\" /></users></computer>" | spath | rename "computer{@N}" as dest, "computer.users.user{@N}" as user, "computer.users.user{@builtinadmin}" as builtinadmin | table dest	user	builtinadmin | rename comment as "Upto now is for sample data only"
| eval t=mvzip(user,builtinadmin,"|")
| mvexpand t
| eval user=mvindex(split(t,"|"),0),builtinadmin=mvindex(split(t,"|"),1)  | table dest	user	builtinadmin

 

 

 

 

Screenshot 2022-03-31 at 11.19.09 PM.png

 

Thanks
KV


If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...