<?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: Compare multi value field with an external file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-multi-value-field-with-an-external-file/m-p/182176#M52541</link>
    <description>&lt;P&gt;I'm assuming your external file is a Splunk lookup, or that you can make it a Splunk lookup. &lt;BR /&gt;
And that your [a,b,c,d,e,f] field is called "foo",  and say there's at least one other field in that lookup that is present on all rows, that we'll call "bar". &lt;BR /&gt;
And also let's assume that in the raw data your multivalue field is called mvField. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;amp;lt;your searchterms&amp;amp;gt; 
| fields mvField (and whatever few other fields you will ultimately need)
| streamstats count as rowId 
| mvexpand mvField 
| lookup foo as mvField OUTPUT bar 
| where isnull(bar)
| stats values(*) as * by rowId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The idea is to use streamstats to paint a unique id on each row,  mvexpand out your multivalue field,  wash it through a lookup,  then discard the rows that actually matched the lookup.  Then finally we use stats values(*) to fold all the expanded rows back up, and end up with mvField being a multivalue field again.  &lt;/P&gt;</description>
    <pubDate>Wed, 06 May 2015 23:27:13 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2015-05-06T23:27:13Z</dc:date>
    <item>
      <title>Compare multi value field with an external file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-multi-value-field-with-an-external-file/m-p/182175#M52540</link>
      <description>&lt;P&gt;I have a multi value field that looks similar to below &lt;BR /&gt;
[a,b]&lt;BR /&gt;
[a,b,c]&lt;BR /&gt;
[b,c]&lt;BR /&gt;
.... so on&lt;/P&gt;

&lt;P&gt;For each event , I want to compare this with an external file that maintains a list and my final result should be the values that do not match&lt;/P&gt;

&lt;P&gt;For eg : my external file contains the following values&lt;BR /&gt;
a b c d e f&lt;/P&gt;

&lt;P&gt;My final result should look like sonething below :&lt;BR /&gt;
[c,d,e,f]&lt;BR /&gt;
[d,e,f]&lt;BR /&gt;
[a,d,e,f]&lt;/P&gt;

&lt;P&gt;Can this be achieved in Splunk ?&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2015 21:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-multi-value-field-with-an-external-file/m-p/182175#M52540</guid>
      <dc:creator>visa87</dc:creator>
      <dc:date>2015-05-06T21:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Compare multi value field with an external file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-multi-value-field-with-an-external-file/m-p/182176#M52541</link>
      <description>&lt;P&gt;I'm assuming your external file is a Splunk lookup, or that you can make it a Splunk lookup. &lt;BR /&gt;
And that your [a,b,c,d,e,f] field is called "foo",  and say there's at least one other field in that lookup that is present on all rows, that we'll call "bar". &lt;BR /&gt;
And also let's assume that in the raw data your multivalue field is called mvField. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;amp;lt;your searchterms&amp;amp;gt; 
| fields mvField (and whatever few other fields you will ultimately need)
| streamstats count as rowId 
| mvexpand mvField 
| lookup foo as mvField OUTPUT bar 
| where isnull(bar)
| stats values(*) as * by rowId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The idea is to use streamstats to paint a unique id on each row,  mvexpand out your multivalue field,  wash it through a lookup,  then discard the rows that actually matched the lookup.  Then finally we use stats values(*) to fold all the expanded rows back up, and end up with mvField being a multivalue field again.  &lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2015 23:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-multi-value-field-with-an-external-file/m-p/182176#M52541</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2015-05-06T23:27:13Z</dc:date>
    </item>
  </channel>
</rss>

