<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Comparing Multivalue Fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551230#M156418</link>
    <description>&lt;P&gt;Appears that mvfind will only match against a regular expression and not a provided field:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/MultivalueEvalFunctions#mvfind.28MVFIELD.2C.22REGEX.22.29" target="_self"&gt;&lt;SPAN&gt;"This function tries to find a value in the multivalue field MVFIELD that matches the regular expression in 'REGEX'"&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2021 12:25:41 GMT</pubDate>
    <dc:creator>wilcomply13</dc:creator>
    <dc:date>2021-05-11T12:25:41Z</dc:date>
    <item>
      <title>Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551128#M156382</link>
      <description>&lt;P&gt;I've done a fair amount of searching over the forums and am still having issues with comparing multi-value fields. I'm attempting to compare src_ip for events against MV field user_known_ip.&lt;BR /&gt;&lt;BR /&gt;Below are the results I expect:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;src_user_ip&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;src_ip&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;KnownIP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;P&gt;192.168.1.1&lt;/P&gt;&lt;P&gt;192.168.1.2&lt;/P&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;P&gt;192.168.1.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;192.168.1.3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;172.16.1.3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;192.168.1.4&lt;/P&gt;&lt;P&gt;192.168.1.5&lt;/P&gt;&lt;P&gt;192.168.1.6&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;172.16.1.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current logic pulls in the necessary events, and does a lookup for user_known_ip:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myindex action=user_login 
| lookup known_user.csv user AS src_user OUTPUT user_ip as src_user_ip  
| makemv delim=" " src_user_ip
| mvexpand src_user_ip
| eval KnownIP = if(match(src_ip, src_user_ip),"Yes", "No")  
| search KnownIP="No" 
| stats values(src_user_ip) values(src_ip) values(KnownIP) by sAMAccountName&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Despite this logic, I'm still having results returned from the base search that contain src_ip values that match values in the MV field src_user_ip:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;src_user_ip&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;src_ip&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;KnownIP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;P&gt;192.168.1.1&lt;/P&gt;&lt;P&gt;192.168.1.2&lt;/P&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;P&gt;192.168.1.1&lt;/P&gt;&lt;P&gt;172.16.1.1&lt;/P&gt;&lt;P&gt;172.16.1.2&lt;/P&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;192.168.1.3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;172.16.1.3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;192.168.1.4&lt;/P&gt;&lt;P&gt;192.168.1.5&lt;/P&gt;&lt;P&gt;192.168.1.6&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;172.16.1.4&lt;/P&gt;&lt;P&gt;172.16.1.5&lt;/P&gt;&lt;P&gt;192.168.1.6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;src_user_ip is multi value and will have an indeterminate number of values.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 18:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551128#M156382</guid>
      <dc:creator>wilcomply13</dc:creator>
      <dc:date>2021-05-10T18:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551132#M156383</link>
      <description>&lt;P&gt;It looks like src_user_ip is a space delimited set of ip so convert it to a regex with alternates and escaping the dots.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="192.168.1.1
172.16.1.3
172.16.1.4"
| rex max_match=0 "(?&amp;lt;src_ip&amp;gt;.+)"
| fields - _*
| mvexpand src_ip
| fields src_ip
| join type=left src_ip 
    [| makeresults
    | eval _raw="src_ip,src_user_ip
192.168.1.1,192.168.1.1 192.168.1.2
192.168.1.3,192.168.1.3
192.168.1.4,192.168.1.4 192.168.1.5 192.168.1.6"
    | multikv forceheader=1
    | fields - _* linecount ]
| eval src_user_ip=replace(replace(src_user_ip,"\.","\\.")," ","|")
| eval knownip=if(match(src_ip,src_user_ip),"yes","no")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then use this in the match against src_ip&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 12:52:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551132#M156383</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-05-11T12:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551134#M156384</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;match&lt;/FONT&gt; function doesn't work with multivalue fields.&amp;nbsp; Try using &lt;FONT face="courier new,courier"&gt;mvfind&lt;/FONT&gt;, instead.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 19:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551134#M156384</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-05-10T19:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551230#M156418</link>
      <description>&lt;P&gt;Appears that mvfind will only match against a regular expression and not a provided field:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/MultivalueEvalFunctions#mvfind.28MVFIELD.2C.22REGEX.22.29" target="_self"&gt;&lt;SPAN&gt;"This function tries to find a value in the multivalue field MVFIELD that matches the regular expression in 'REGEX'"&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 12:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551230#M156418</guid>
      <dc:creator>wilcomply13</dc:creator>
      <dc:date>2021-05-11T12:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551232#M156419</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;match&lt;/FONT&gt; function has a similar description and yet you still tried it with a field.&amp;nbsp; Did you try &lt;FONT face="courier new,courier"&gt;mvfind&lt;/FONT&gt; with a field?&amp;nbsp; Note, in both functions the value of the provided field will be treated as a regular expression.&amp;nbsp; This means certain special characters may need to be escaped.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 12:38:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551232#M156419</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-05-11T12:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551242#M156423</link>
      <description>&lt;P&gt;My apologies, you are correct. I was misinterpreting the output. This is a working solution for this issue.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 13:53:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/551242#M156423</guid>
      <dc:creator>wilcomply13</dc:creator>
      <dc:date>2021-05-11T13:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/563862#M196413</link>
      <description>&lt;P&gt;I would recommend a more direct approach using something meant to solve the issue without extra SPL such as parsing, expanding, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, while the given accepted answer provides a solution to your particular use case in that you just need a yes/no to the existence of overlapping values. A command such as this one could also provide you with what those values actually are.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/5694/" target="_blank" rel="noopener"&gt;MVCompare | Splunkbase&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 02:23:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/563862#M196413</guid>
      <dc:creator>theChain</dc:creator>
      <dc:date>2021-08-23T02:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/599943#M208833</link>
      <description>&lt;P&gt;I had to deal with this today - more in the context of "what was added or dropped between multivalue (MV) field A and MV field B", but the solution also lets you find the intersection between two MV fields.&lt;/P&gt;&lt;P&gt;This approach avoids the expensive mvexpand command.&lt;/P&gt;&lt;P&gt;The trick is to use mvmap() to do an operation on each value of one of the values in the MV field, and test to see if that value is in the other MV field. Technically, mvfind() takes a regex, so be careful with MV field values with regex-special characters in them.&lt;/P&gt;&lt;P&gt;Here's an example:&lt;/P&gt;&lt;PRE&gt;| makeresults | eval A="a, b, c", B="z, c, e, d" | makemv delim=", " A | makemv delim=", " B&lt;BR /&gt;| eval&lt;BR /&gt;&amp;nbsp;``` loop through each value of B. if the value is not found in A, add the value to a resulting mv field returned. ``` &lt;BR /&gt;  added=mvmap(B, if(isnull(mvfind(A, B)), B, null())),&lt;BR /&gt;&amp;nbsp;``` loop through each value of A. if the value is not found in B, add the value to a resulting mv field returned. ``` &lt;BR /&gt;  removed=mvmap(A, if(isnull(mvfind(B, A)), A, null())),&lt;BR /&gt;&amp;nbsp;``` loop through each value of A. if the value IS found in B, add the value to a resulting mv field returned. ``` &lt;BR /&gt;  same=mvmap(A, if(isnotnull(mvfind(B, A)), A, null))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 15:59:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/599943#M208833</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2022-05-31T15:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/599949#M208835</link>
      <description>&lt;P&gt;Note my response and included command would do this and more with 5/6 less commands in an inexpensive manner.&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 16:33:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/599949#M208835</guid>
      <dc:creator>theChain</dc:creator>
      <dc:date>2022-05-31T16:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Multivalue Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/699218#M237388</link>
      <description>&lt;P&gt;Exactly what I needed and all I had to do was substitute my field names.&amp;nbsp; Worked like a charm.&amp;nbsp; Karma for you.&amp;nbsp; Thanks !&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 19:35:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-Multivalue-Fields/m-p/699218#M237388</guid>
      <dc:creator>colbym</dc:creator>
      <dc:date>2024-09-16T19:35:53Z</dc:date>
    </item>
  </channel>
</rss>

