Splunk Search

How to compare and show the difference between two mv fields?

taynord
Engager

I have two mvfields and am looking for a way to show the difference (the missing fields) when comparing mvfield req to mvfield res

req
34
228
12558

res
34
228

how do I create a third field that would contain 12558?

0 Karma
1 Solution

vnravikumar
Champion

Hi

Give a try

| makeresults 
| eval req="34,228,12558" 
| appendcols 
    [| makeresults 
    | eval res="228,34,4" 
        ] 
| eval diff = req.",".res 
| makemv delim="," diff 
| stats count,list(req) as req,list(res) as res by diff 
| where count =1 
| mvcombine diff delim="," 
| nomv diff 
| table req,res,diff

View solution in original post

vnravikumar
Champion

Hi

Give a try

| makeresults 
| eval req="34,228,12558" 
| appendcols 
    [| makeresults 
    | eval res="228,34,4" 
        ] 
| eval diff = req.",".res 
| makemv delim="," diff 
| stats count,list(req) as req,list(res) as res by diff 
| where count =1 
| mvcombine diff delim="," 
| nomv diff 
| table req,res,diff

taynord
Engager

this works for me thanks!

| eval diff = mvzip(req,res)
| makemv delim="," diff 
| stats count,list(req) as req,list(res) as res by diff
 | where count =1 
 | mvcombine diff delim="," 
 | nomv diff 
 | table req,res,diff
0 Karma

woodcock
Esteemed Legend

I am pretty sure that this only works for simple cases so be sure to evaluate deeply.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...