<?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 How to set &amp;quot;abnormal&amp;quot; tallies to null after timechart/chart? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657247#M227008</link>
    <description>&lt;P&gt;I have an unstable data feed that sometimes only reports on a fraction of all assets. &amp;nbsp;I do not want such periods to show any number. &amp;nbsp;The best way I can figure to exclude those time period is to see if there is a sudden drop of some sort of total. &amp;nbsp;So, I set up a condition after timechart like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals
| delta "Total" as delta
| foreach *
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(-delta &amp;gt; Total OR Total &amp;lt; 5000, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/LI-CODE&gt;&lt;P&gt;The algorithm works well for Total, and for some series in timechart, but not for all, not all the time.&lt;/P&gt;&lt;P&gt;Here are two emulations using index=_internal on my laptop. &amp;nbsp;One groups by source, the other groups by sourcetype.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal earliest=-7d
| timechart span=2h count by source
``` data emulation 1 ```&lt;/LI-CODE&gt;&lt;P&gt;With group by source, all series seem to blank out as expected.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="set-null-source.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27124i5B98970AB922D1CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="set-null-source.png" alt="set-null-source.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, I can run the same tally by sourcetype, like thus&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal earliest=-7d
| timechart span=2h count by sourcetype
``` data emulation 2 ```&lt;/LI-CODE&gt;&lt;P&gt;This time, all gaps have at least one series that is not null; some series go to zero instead of null, some even obviously above zero.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="set-null-sourcetype.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27125iC9BAB062EE5FB904/image-size/medium?v=v2&amp;amp;px=400" role="button" title="set-null-sourcetype.png" alt="set-null-sourcetype.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What is the determining factor here?&lt;/P&gt;&lt;P&gt;If you have suggestion about alternative approaches, I would also appreciate.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 00:39:04 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-09-12T00:39:04Z</dc:date>
    <item>
      <title>How to set "abnormal" tallies to null after timechart/chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657247#M227008</link>
      <description>&lt;P&gt;I have an unstable data feed that sometimes only reports on a fraction of all assets. &amp;nbsp;I do not want such periods to show any number. &amp;nbsp;The best way I can figure to exclude those time period is to see if there is a sudden drop of some sort of total. &amp;nbsp;So, I set up a condition after timechart like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals
| delta "Total" as delta
| foreach *
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(-delta &amp;gt; Total OR Total &amp;lt; 5000, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/LI-CODE&gt;&lt;P&gt;The algorithm works well for Total, and for some series in timechart, but not for all, not all the time.&lt;/P&gt;&lt;P&gt;Here are two emulations using index=_internal on my laptop. &amp;nbsp;One groups by source, the other groups by sourcetype.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal earliest=-7d
| timechart span=2h count by source
``` data emulation 1 ```&lt;/LI-CODE&gt;&lt;P&gt;With group by source, all series seem to blank out as expected.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="set-null-source.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27124i5B98970AB922D1CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="set-null-source.png" alt="set-null-source.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, I can run the same tally by sourcetype, like thus&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal earliest=-7d
| timechart span=2h count by sourcetype
``` data emulation 2 ```&lt;/LI-CODE&gt;&lt;P&gt;This time, all gaps have at least one series that is not null; some series go to zero instead of null, some even obviously above zero.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="set-null-sourcetype.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27125iC9BAB062EE5FB904/image-size/medium?v=v2&amp;amp;px=400" role="button" title="set-null-sourcetype.png" alt="set-null-sourcetype.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What is the determining factor here?&lt;/P&gt;&lt;P&gt;If you have suggestion about alternative approaches, I would also appreciate.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 00:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657247#M227008</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-09-12T00:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to set "abnormal" tallies to null after timechart/chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657252#M227012</link>
      <description>&lt;P&gt;Your foreach eval statement is wrong, it should test for Total and delta fields&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if("&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"!="Total" AND "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"!="delta" AND -delta &amp;gt; Total OR Total &amp;lt; 5000, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/LI-CODE&gt;&lt;P&gt;You are not excluding 'delta' and 'Total' fields from the eval, so Total is set to null() before you process the other fields, so breaks the eval for subsequent passes.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 02:21:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657252#M227012</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-12T02:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to set "abnormal" tallies to null after timechart/chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657267#M227020</link>
      <description>&lt;P&gt;Excellent, thanks for the diagnosis! &amp;nbsp;So, the ASCII order in * enumeration ruined the conditions. &amp;nbsp;In my emulations, source series begin with a slash (/) that precedes T, but sourcetype series all begin with a lower-case letter that succeeds T. &amp;nbsp;This explains why the two groupby's behave differently.&lt;/P&gt;&lt;P&gt;But I still need to null out Total. &amp;nbsp;So, a better (and yet simpler) approach is to place "Total" at the end of enumeration taking advantage of Splunk's globber rule:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals
| delta "Total" as delta
| foreach * Total delta
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(-delta &amp;gt; Total OR Total &amp;lt; 5000, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| fields - delta&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update: In real world, it is often undesirable to use arbitrary thresholds like Total &amp;lt; 5000. &amp;nbsp;For this technique to work, I also need to make sure all other fields are nulled before delta. &amp;nbsp;&lt;STRIKE&gt;So, I must expressly specify the order of these two fields in foreach.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;Update 2: In addition to wanting to nullify Total, I also need to remove delta.&amp;nbsp; So, my best approach would be a hybrid of hacking field name and ensuring order:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals
| delta "Total" as _delta
| foreach * Total
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(-_delta &amp;gt; Total OR Total &amp;lt; 5000, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/LI-CODE&gt;&lt;P&gt;This way, field deletion is also unnecessary.&amp;nbsp; Thanks again, &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; for the inspiration!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 00:47:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657267#M227020</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-09-13T00:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to set "abnormal" tallies to null after timechart/chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657277#M227023</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or you can use the _ field prefix to hide it from the foreach, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals fieldname=_T
| delta "_T" as _delta
| foreach *
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(-'_delta' &amp;gt; '_T' OR '_T' &amp;lt; 5000, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
``` To show that the _ fields are present ```
| eval y=_T, x=_delta&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Sep 2023 07:20:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657277#M227023</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-12T07:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to set "abnormal" tallies to null after timechart/chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657354#M227055</link>
      <description>&lt;P&gt;Nice! &amp;nbsp;Love these little Splunk quirks aka tricks. (For anyone who stumble upon the same needs in the future, using _ would be perfect if Total doesn't have to be nullified.&amp;nbsp; I need to null Total, so the amount of work will be similar to reorder foreach.)&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 19:57:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-quot-abnormal-quot-tallies-to-null-after-timechart/m-p/657354#M227055</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-09-12T19:57:36Z</dc:date>
    </item>
  </channel>
</rss>

