<?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: How to exclude duplicate events based on a field value in another event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496139#M138281</link>
    <description>&lt;P&gt;Thanks a lot! I'll accept your original answer as &lt;EM&gt;the&lt;/EM&gt; answer as it is the solution to the original question. I appreciate your help.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Oct 2019 13:14:11 GMT</pubDate>
    <dc:creator>russell120</dc:creator>
    <dc:date>2019-10-02T13:14:11Z</dc:date>
    <item>
      <title>How to exclude duplicate events based on a field value in another event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496135#M138277</link>
      <description>&lt;P&gt;Hi, I have an "asset discovery" type of query that uses a CSV and 4+ indexes, and produces tens of thousands of results look similar to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id     device     serial  origin
111  routerAlpha  12345   sales
     routerAlpha  12345
222  switchBeta   78787   devops
     switchBeta   78787   
    desktopSigma  44444   
    desktopSigma  44444   
    serverTheta   55555   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I:&lt;BR /&gt;
1) Remove all events that have a &lt;CODE&gt;serial&lt;/CODE&gt; with a null &lt;CODE&gt;id&lt;/CODE&gt; &lt;STRONG&gt;IF&lt;/STRONG&gt; the same &lt;CODE&gt;serial&lt;/CODE&gt; appears again in an event &lt;EM&gt;with&lt;/EM&gt; a numerical id&lt;BR /&gt;
2) Then, deduplicate all other events that have a &lt;CODE&gt;serial&lt;/CODE&gt; # with a null &lt;CODE&gt;id&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The result should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id     device     serial  origin
111  routerAlpha  12345   sales
222  switchBeta   78787   devops
    desktopSigma  44444   
    serverTheta   55555   
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2019 16:48:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496135#M138277</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-09-30T16:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude duplicate events based on a field value in another event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496136#M138278</link>
      <description>&lt;P&gt;Greetings @russell120,&lt;/P&gt;

&lt;P&gt;This run-anywhere search should give you what you need. &lt;CODE&gt;Fillnull&lt;/CODE&gt; is necessary so that &lt;CODE&gt;stats&lt;/CODE&gt; does not drop the null entries. Then, you count the number of unique device rows. If there are multiple device rows AND id is null, then drop those. You can use whatever you want instead of "-", and you can use &lt;CODE&gt;replace&lt;/CODE&gt; to change back to null if necessary at the end.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;           | makeresults | eval id="111"   , device="routerAlpha" ,  serial="12345" , origin="sales"
| append [ | makeresults | eval id=null()  , device="routerAlpha" ,  serial=null()  , origin=null()   ]
| append [ | makeresults | eval id="222"   , device="switchBeta"  ,  serial="78787" , origin="devops" ]
| append [ | makeresults | eval id=null()  , device="switchBeta"  ,  serial="78787" , origin=null()   ]
| append [ | makeresults | eval id=null()  , device="desktopSigma",  serial="44444" , origin=null()   ]
| append [ | makeresults | eval id=null()  , device="desktopSigma",  serial="44444" , origin=null()   ]
| append [ | makeresults | eval id=null()  , device="serverTheta" ,  serial="55555" , origin=null()   ]
| fillnull value="-"
| stats      count by id device serial origin
| eventstats count by device
| search NOT(count&amp;gt;1 id="-")
| fields   - count
| sort                id device serial
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2019 20:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496136#M138278</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-09-30T20:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude duplicate events based on a field value in another event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496137#M138279</link>
      <description>&lt;P&gt;Hey @jacobevans , &lt;/P&gt;

&lt;P&gt;Thanks! This works perfectly for the example I provided, but perhaps I simplified my real data a bit too much. My issue is that I have a multivalue field.&lt;/P&gt;

&lt;P&gt;If &lt;CODE&gt;origin&lt;/CODE&gt; was a &lt;EM&gt;multivalue&lt;/EM&gt; field and the values &lt;CODE&gt;sales&lt;/CODE&gt; and &lt;CODE&gt;devops&lt;/CODE&gt; were replaced with &lt;CODE&gt;sales marketing&lt;/CODE&gt; and &lt;CODE&gt;devops tech&lt;/CODE&gt;, respectively, what edit would we need in your solution for it to work?&lt;/P&gt;

&lt;P&gt;Since I have a multivalue field, the &lt;CODE&gt;stats count by&lt;/CODE&gt; line (line 9) makes a 2nd copy of each event to separate the multivalues into their own a single value.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 17:46:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496137#M138279</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-10-01T17:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude duplicate events based on a field value in another event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496138#M138280</link>
      <description>&lt;P&gt;Try inserting &lt;CODE&gt;| mvexpand origin&lt;/CODE&gt; between these lines:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fillnull value="-"
| stats      count by id device serial origin
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So that it now looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            | makeresults | eval id="111"   , device="routerAlpha" ,  serial="12345" , origin="sales"
 | append [ | makeresults | eval id=null()  , device="routerAlpha" ,  serial=null()  , origin=null()   ]
 | append [ | makeresults | eval id="222"   , device="switchBeta"  ,  serial="78787" , origin="devops" ]
 | append [ | makeresults | eval id=null()  , device="switchBeta"  ,  serial="78787" , origin=null()   ]
 | append [ | makeresults | eval id=null()  , device="desktopSigma",  serial="44444" , origin=null()   ]
 | append [ | makeresults | eval id=null()  , device="desktopSigma",  serial="44444" , origin=null()   ]
 | append [ | makeresults | eval id=null()  , device="serverTheta" ,  serial="55555" , origin=null()   ]
 | fillnull value="-"
 | mvexpand origin
 | stats      count by id device serial origin
 | eventstats count by device
 | search NOT(count&amp;gt;1 id="-")
 | fields   - count
 | sort                id device serial
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Without testing, I believe that should work.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 18:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496138#M138280</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-10-01T18:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude duplicate events based on a field value in another event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496139#M138281</link>
      <description>&lt;P&gt;Thanks a lot! I'll accept your original answer as &lt;EM&gt;the&lt;/EM&gt; answer as it is the solution to the original question. I appreciate your help.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 13:14:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496139#M138281</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-10-02T13:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude duplicate events based on a field value in another event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496140#M138282</link>
      <description>&lt;P&gt;You got it. Thank you for accepting the answer!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 21:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-duplicate-events-based-on-a-field-value-in/m-p/496140#M138282</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-10-02T21:15:23Z</dc:date>
    </item>
  </channel>
</rss>

