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.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...