<?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 omit from a timechart series that include only zeroes? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38734#M8825</link>
    <description>&lt;P&gt;I'd like to timechart throughput, by queue, in a message broker: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="jms-queue" queue_name="SNMPTrapsQueue*" | timechart span=5m per_minute(count_delta) by queue_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The majority of these queues remain empty.  For those queues, throughput is represented by a series of zeroes. I'd like the chart to ignore those series (i.e. the timechart would only display active queues).  &lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2011 21:52:42 GMT</pubDate>
    <dc:creator>anssntaco</dc:creator>
    <dc:date>2011-12-21T21:52:42Z</dc:date>
    <item>
      <title>How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38734#M8825</link>
      <description>&lt;P&gt;I'd like to timechart throughput, by queue, in a message broker: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="jms-queue" queue_name="SNMPTrapsQueue*" | timechart span=5m per_minute(count_delta) by queue_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The majority of these queues remain empty.  For those queues, throughput is represented by a series of zeroes. I'd like the chart to ignore those series (i.e. the timechart would only display active queues).  &lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2011 21:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38734#M8825</guid>
      <dc:creator>anssntaco</dc:creator>
      <dc:date>2011-12-21T21:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38735#M8826</link>
      <description>&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="jms-queue" 
[search source="jms-queue" earliest=-1h | stats sum(throughput) as total by queue_name | 
  where total &amp;gt; 0 | fields + queue_name] 
| timechart span=5m per_minute(count_delta) by queue_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second and third lines define a sub-search, which will return a list of queue_names.  The subsearch sums all the throughput for each queue, and only returns the queue_names with &amp;gt; 0 throughput.  You will need to replace &lt;CODE&gt;throughput&lt;/CODE&gt; in the second line with the proper field name.  Note that you may also need to change the earliest=-1h to match your requirements (and perhaps add latest= as well).&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2011 12:56:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38735#M8826</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2011-12-27T12:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38736#M8827</link>
      <description>&lt;P&gt;I had the same question, saw the accepted answer, and decided to develop my own solution.&lt;/P&gt;

&lt;P&gt;Some reasons &lt;EM&gt;not&lt;/EM&gt; to add my answer:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;The question is several years old&lt;/LI&gt;
&lt;LI&gt;An answer has already been accepted&lt;/LI&gt;
&lt;LI&gt;The accepted answer was by someone with high karma points&lt;/LI&gt;
&lt;LI&gt;I'm a Splunk newbie, so I might well be missing something here&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Reasons to do it:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;My answer performs processing &lt;EM&gt;after&lt;/EM&gt; &lt;CODE&gt;timechart&lt;/CODE&gt;, which might be more performant than the accepted answer (Lisa, your thoughts on this?)&lt;/LI&gt;
&lt;LI&gt;Even if my answer is wrong, I hope I'll learn something from subsequent comments, probably from @lguinn &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;My answer (with line breaks for readability):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart ... by queue_name
| foreach * [eval nonzero_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'==0 OR "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"==_time, null(), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| fields _time nonzero_*
| rename nonzero_* as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's the "trick": if you assign a null value by calling the function &lt;CODE&gt;null()&lt;/CODE&gt;, the &lt;CODE&gt;eval&lt;/CODE&gt; command does not create a field.&lt;/P&gt;

&lt;P&gt;So, the &lt;CODE&gt;foreach&lt;/CODE&gt; command only creates a &lt;CODE&gt;nonzero_*&lt;/CODE&gt; field if the original field has at least one nonzero value.&lt;/P&gt;

&lt;P&gt;The subsequent &lt;CODE&gt;fields&lt;/CODE&gt; command only keeps the &lt;CODE&gt;_time&lt;/CODE&gt; field and any &lt;CODE&gt;nonzero_*&lt;/CODE&gt; fields.&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;rename&lt;/CODE&gt; command reverts to the original field names.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 08:22:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38736#M8827</guid>
      <dc:creator>Graham_Hanningt</dc:creator>
      <dc:date>2016-04-29T08:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38737#M8828</link>
      <description>&lt;P&gt;Your solution is more efficient that the accepted answer.  However, note that expression for NULL in eval is actually a function call of null().  It probably seems to work because NULL is treated as a field with the name NULL, which probably doesn't exist in your environment.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 21:36:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38737#M8828</guid>
      <dc:creator>steveyz</dc:creator>
      <dc:date>2016-04-29T21:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38738#M8829</link>
      <description>&lt;P&gt;I believe the simplest solution to this is to simply filter out events where count_delta=0, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="jms-queue" queue_name="SNMPTrapsQueue*" count_delta&amp;gt;0 | timechart span=5m per_minute(count_delta) by queue_name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Apr 2016 21:38:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38738#M8829</guid>
      <dc:creator>steveyz</dc:creator>
      <dc:date>2016-04-29T21:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38739#M8830</link>
      <description>&lt;P&gt;Yes, for the original poster's specific use case, based on the information provided here, I agree.&lt;/P&gt;

&lt;P&gt;However, while I came here looking for an answer to the same one-liner question, "How to omit from a timechart series that include only zeroes?", my use case is slightly different. In my case, each event represents a database request. Each event contains, among many other fields, nine "suspend clock" fields, representing the different ways in which a database request might be suspended. Requests can be suspended in a combination of these ways. I want to visualize these suspend time "components" together, on a single chart. But I want (as per the question) to omit any series whose values are all zero. So, I can't simply omit events with a zero value in one of these fields.&lt;/P&gt;

&lt;P&gt;That was another reason for me to add my answer (although I was hesitant to do so, not wishing to offend or break etiquette): it occurred to me that other users might also have the same (one-liner) question, but with a use case closer to mine.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 02:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38739#M8830</guid>
      <dc:creator>Graham_Hanningt</dc:creator>
      <dc:date>2016-05-02T02:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38740#M8831</link>
      <description>&lt;P&gt;Face slap :-). Thanks, @steveyz. I've edited my answer and replaced &lt;CODE&gt;NULL&lt;/CODE&gt; with &lt;CODE&gt;null()&lt;/CODE&gt; (and tested that this still works).&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 02:25:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38740#M8831</guid>
      <dc:creator>Graham_Hanningt</dc:creator>
      <dc:date>2016-05-02T02:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38741#M8832</link>
      <description>&lt;P&gt;@Graham_Hannington - never be afraid to add to the discussion! Overall this is a friendly community, and things only get "touchy"  around downvoting. (FYI, the general etiquette is to only downvote answers that are wrong or would cause harm if implemented.) Quite frequently, there is more than one way to do things in Splunk - I like it when someone finds a better answer. I love it when someone explains why the new answer is better.&lt;/P&gt;

&lt;P&gt;In addition, older answers often need a "tune-up." And I hope that I've learned some stuff in the last 5 years, too!&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 17:50:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38741#M8832</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-05-10T17:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38742#M8833</link>
      <description>&lt;P&gt;New answer: if I were writing this search today, I would definitely &lt;EM&gt;not&lt;/EM&gt; use a subsearch. I would use @steveyz's solution if possible.&lt;BR /&gt;
But here is another way to do it - which will work when the selection field does not already exist, or is not the appropriate way to select events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="jms-queue" 
| eventstats sum(throughput) as total by queue_name
| where total &amp;gt; 0 
| timechart span=5m per_minute(count_delta) by queue_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will definitely be faster than the original answer. While the "for each" solution may work, it seems overly complex and "feels procedural." I feel this solution aligns better with the "pipeline" perspective of Splunk .&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 18:08:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38742#M8833</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-05-10T18:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38743#M8834</link>
      <description>&lt;P&gt;I would avoid eventstats if the search is over a lot of events.  While the "for each" solution is seems overly complicated, it would be far more efficient performance wise (especially for a distributed deployment with many indexers) if dealing with more than a few hundred thousand events.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 18:19:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38743#M8834</guid>
      <dc:creator>steveyz</dc:creator>
      <dc:date>2016-05-10T18:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit from a timechart series that include only zeroes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38744#M8835</link>
      <description>&lt;P&gt;What about this for efficiency and ease?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="jms-queue" 
| bin _time span=5m
| stats per_minute(count_delta) as dpm by queue_name _time
| addtotals
| where total &amp;gt; 0
| fields - total
| xyseries _time queue_name dpm
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;One pass through the data, then eliminate queues that have total count_delta = 0. Finally, put the data in timechart format.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 17:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-omit-from-a-timechart-series-that-include-only-zeroes/m-p/38744#M8835</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-05-11T17:52:22Z</dc:date>
    </item>
  </channel>
</rss>

