<?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: Remove erroneous results from a search in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369859#M9591</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/147603"&gt;@dbcase&lt;/a&gt; - We're going to pull the solution from the other question, and then show you how to engineer it into this question.  &lt;/P&gt;

&lt;P&gt;What we need to do is to take all the different Trouble events, pipe them through an "appendpipe" that uses the code we developed over there to collapse them, then keep all the new ones for this EVENT_TYPE and delete all the old ones.&lt;/P&gt;

&lt;P&gt;Looking a little deeper, we note that we need to add back the EVENT_TYPE and EVENT_SUB_TYPE because we'll need them for your graph.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search that gets the records EVENT_TYPE=*Trouble*
| fields _time ID PREMISE_FK EVENT_TYPE EVENT_SUB_TYPE
| appendpipe 
    [| where EVENT_TYPE="Camera Trouble"
     | stats max(_time) as Time 
            max(eval(case(EVENT_SUB_TYPE="com",_time))) as comTime 
            max(eval(case(EVENT_SUB_TYPE="comRes",_time))) as resTime 
        by ID PREMISE_FK EVENT_TYPE
     | where isnull(resTime) OR resTime&amp;lt;comTime
     | rename Time as _time
     | eval EVENT_SUB_TYPE="com"
     | eval keepme="keepme" 
     | fields _time ID PREMISE_FK EVENT_TYPE EVENT_SUB_TYPE
    ]
| where (EVENT_TYPE!="Camera Trouble") OR (keepme="keepme")
| fields - keepme
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We'll assume the rest of your search looks something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval TROUBLE = EVENT_TYPE." - ".EVENT_SUB_TYPE
 | top 10 TROUBLE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval TROUBLE = EVENT_TYPE." - ".EVENT_SUB_TYPE
 | stats count by TROUBLE
 | sort 10 - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above assumes there is no reason to show comRes events in the output.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 15:59:37 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2020-09-29T15:59:37Z</dc:date>
    <item>
      <title>Remove erroneous results from a search</title>
      <link>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369856#M9588</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have this data&lt;BR /&gt;
2017-09-27 15:56:42 ID="108065999", PREMISE_FK="1004152", EVENT_TYPE="Camera Trouble", EVENT_SUB_TYPE="com"&lt;/P&gt;

&lt;P&gt;2017-09-27 15:56:45 ID="108065999", PREMISE_FK="1004152", EVENT_TYPE="Camera Trouble", EVENT_SUB_TYPE="comRes"&lt;/P&gt;

&lt;P&gt;2017-09-27 15:56:42 ID="108065671", PREMISE_FK="1001566", EVENT_TYPE="Camera Trouble", EVENT_SUB_TYPE="com"&lt;/P&gt;

&lt;P&gt;Goes on for 4500 events with various different event types.  Camera trouble is just one.&lt;/P&gt;

&lt;P&gt;Event #1 is a communication failure for a given premise ID&lt;BR /&gt;
Event #2 is a communication restore for the same premise ID in event #1&lt;BR /&gt;
Event #3 is a communication failure for a different premise ID&lt;/P&gt;

&lt;P&gt;If there is a failure and a subsequent restore I want to ignore it, but if there is a failure without a subsequent restore (Event #3) I want to report on it? How would I go about getting a premise ID and searching the same event log for each premise ID??&lt;/P&gt;

&lt;P&gt;I need to end up with a graph like the below.  As you can see by the graph there is one device that is flapping that is skewing the results.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/217710-chart.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:03:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369856#M9588</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T16:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Remove erroneous results from a search</title>
      <link>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369857#M9589</link>
      <description>&lt;P&gt;You can do so by utilizing the transaction command.&lt;BR /&gt;
If you want something less processing intensive you can do so by evaluating a new field, maybe "status", and then use stats.  For instance:&lt;/P&gt;

&lt;P&gt;A very simple example might look like&lt;BR /&gt;
&lt;CODE&gt;eval status=if(EVENT_TYPE=="Trouble" AND EVENT_SUB_TYPE=="comRes", "Good", "Bad") | stats latest(status) as LatestStatus | where LatestStatus=="Bad"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This would indicate all that are still bad and can be alerted on.  Should get you started - will definitely need tweaking.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 17:09:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369857#M9589</guid>
      <dc:creator>hortonew</dc:creator>
      <dc:date>2017-09-29T17:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Remove erroneous results from a search</title>
      <link>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369858#M9590</link>
      <description>&lt;P&gt;For each Camera trouble incident, does a new Promise ID (PREMISE_FK) is created (means every failure is unique)?? If yes, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | stats list(EVENT_SUB_TYPE) as EVENT_SUB_TYPE by PREMISE_FK, EVENT_TYPE
| where mvcount(EVENT_SUB_TYPE)=1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Sep 2017 17:30:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369858#M9590</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-29T17:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Remove erroneous results from a search</title>
      <link>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369859#M9591</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/147603"&gt;@dbcase&lt;/a&gt; - We're going to pull the solution from the other question, and then show you how to engineer it into this question.  &lt;/P&gt;

&lt;P&gt;What we need to do is to take all the different Trouble events, pipe them through an "appendpipe" that uses the code we developed over there to collapse them, then keep all the new ones for this EVENT_TYPE and delete all the old ones.&lt;/P&gt;

&lt;P&gt;Looking a little deeper, we note that we need to add back the EVENT_TYPE and EVENT_SUB_TYPE because we'll need them for your graph.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search that gets the records EVENT_TYPE=*Trouble*
| fields _time ID PREMISE_FK EVENT_TYPE EVENT_SUB_TYPE
| appendpipe 
    [| where EVENT_TYPE="Camera Trouble"
     | stats max(_time) as Time 
            max(eval(case(EVENT_SUB_TYPE="com",_time))) as comTime 
            max(eval(case(EVENT_SUB_TYPE="comRes",_time))) as resTime 
        by ID PREMISE_FK EVENT_TYPE
     | where isnull(resTime) OR resTime&amp;lt;comTime
     | rename Time as _time
     | eval EVENT_SUB_TYPE="com"
     | eval keepme="keepme" 
     | fields _time ID PREMISE_FK EVENT_TYPE EVENT_SUB_TYPE
    ]
| where (EVENT_TYPE!="Camera Trouble") OR (keepme="keepme")
| fields - keepme
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We'll assume the rest of your search looks something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval TROUBLE = EVENT_TYPE." - ".EVENT_SUB_TYPE
 | top 10 TROUBLE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval TROUBLE = EVENT_TYPE." - ".EVENT_SUB_TYPE
 | stats count by TROUBLE
 | sort 10 - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above assumes there is no reason to show comRes events in the output.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:59:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369859#M9591</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T15:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Remove erroneous results from a search</title>
      <link>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369860#M9592</link>
      <description>&lt;P&gt;Hi DalJeanis,&lt;/P&gt;

&lt;P&gt;I ended up using yours but then adding an additional stats command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cg_troubles|rex "(?i) PREMISE_FK=\"(?P&amp;lt;premise&amp;gt;[^\"]+)"|rex "(?i) EVENT_TYPE=\"(?P&amp;lt;event_type&amp;gt;[^\"]+)"|rex "(?i) .*?=\"(?P&amp;lt;EVENT_SUB_TYPE&amp;gt;[a-z]+)(?=\")"|stats max(_time) as Time 
         max(eval(case(EVENT_SUB_TYPE="com",_time))) as comTime 
         max(eval(case(EVENT_SUB_TYPE="comRes",_time))) as resTime 
    values(event_type) as et values(EVENT_SUB_TYPE) as est by premise  
 | where isnull(resTime) OR resTime&amp;lt;comTime
 | rename Time as _time|eval ts=et+" - "+est|stats count by ts|sort by -count|head 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Sep 2017 20:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Remove-erroneous-results-from-a-search/m-p/369860#M9592</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-09-29T20:41:10Z</dc:date>
    </item>
  </channel>
</rss>

