<?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 produce empty time buckets in Deployment Architecture</title>
    <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172337#M6451</link>
    <description>&lt;P&gt;This was pretty helpful to get me going, thought I'd share my finished product w/ others if they might find it useful.  What I needed to do was get data for each minutely timebucket in a stats call of mine, but I had multiple fields that I was pivoting on so the solution had to be expanded upon a bit.  Here's what I did:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search |bucket _time span=1m| stats sum(field1) as field1 avg(field2) as field2 by field3 field4 _time| appendpipe [|inputlookup field3_lookup |table field3 | dedup field3 |stats values(field3)  |addinfo | eval temp=info_min_time."##".info_max_time | makemv temp delim="##" | mvexpand temp  | eval _time=temp | timechart span=1m values(field3) as field3 | eval field3=mvjoin(field3,";") | streamstats last(field3) as field3 | makemv delim=";" field3 | mvexpand field3 | eval field1=0 | eval field2=0 | eval field4="possibility1;possibility2;possiblity3" | makemv field4 delim=";"| mvexpand field4]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The lookup contains all possible values for field3, so basically filling out all possible values that could show up in the base stats call, then afterward further down the line not pictured I do an sistats call that gets me everything I want and now has "0" values for time buckets that otherwise wouldn't show up for certain variants of field3 and field4&lt;/P&gt;</description>
    <pubDate>Wed, 21 Feb 2018 23:35:36 GMT</pubDate>
    <dc:creator>briancronrath</dc:creator>
    <dc:date>2018-02-21T23:35:36Z</dc:date>
    <item>
      <title>How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172323#M6437</link>
      <description>&lt;P&gt;In order to perform fast Fourier transform (FFT), I need data from equal time intervals.  Here is my first attempt:&lt;BR /&gt;
&lt;CODE&gt;| bucket span=5m _time | stats count as COUNT by _time&lt;/CODE&gt;&lt;BR /&gt;
The idea is to use bins for sampling.  However, this doesn't work when no events occur in some bins.   Splunk will not output rows for any bin in which COUNT = 0 because _raw doesn't contain such data.  Is there some way to force/coerce Splunk into producing empty time buckets?&lt;/P&gt;

&lt;P&gt;FFT (in R app) is the most hopeful tool for spectrum analysis.  Before I explore interpolation in an external tool, I'd like to see if there is a direct Splunk method.  I understand that there may not be a meaningful way to fill empty buckets in general.   But calendar time is defined in the system, so there should be an easy way to force it.&lt;/P&gt;

&lt;P&gt;I looked at zero-count discussions.   One post suggests a subsearch over dense data, i.e., data sets that have non-zero counts in each of desired time bucket.  Whereas in my range this is possible, this appears to be a really expensive way to implement a simple calendaring function.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2014 23:35:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172323#M6437</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2014-08-05T23:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172324#M6438</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Could you try to use "timechart" instead of "bucket"?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search) | timechart span=5m count AS COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You may also get COUNT=0 events. I hope it helps you.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2014 02:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172324#M6438</guid>
      <dc:creator>Suda</dc:creator>
      <dc:date>2014-08-06T02:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172325#M6439</link>
      <description>&lt;P&gt;when raw data itself is not for some buckets, you need those buckets as well. is that right understanding?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2014 05:46:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172325#M6439</guid>
      <dc:creator>strive</dc:creator>
      <dc:date>2014-08-06T05:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172326#M6440</link>
      <description>&lt;P&gt;Yes, that's what I need.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2014 07:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172326#M6440</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2014-08-06T07:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172327#M6441</link>
      <description>&lt;P&gt;timechart works, as long as start and end buckets have data.  Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2014 07:57:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172327#M6441</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2014-08-06T07:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172328#M6442</link>
      <description>&lt;P&gt;Try this workaround&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | timechart span=1h count | appendpipe [|stats count |addinfo | eval temp=info_min_time."##".info_max_time | makemv temp delim="##" | mvexpand temp | eval count=0 | eval _time=temp | table _time count] | timechart span=1h sum(count) as count | fillnull
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Aug 2014 16:14:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172328#M6442</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-06T16:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172329#M6443</link>
      <description>&lt;P&gt;Subsearch using calendar.  This fills all, even missing start and end buckets.  Brilliant!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2014 17:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172329#M6443</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2014-08-06T17:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172330#M6444</link>
      <description>&lt;P&gt;timechart has a very undesirable feature for this purpose: It insists on one extra data point beyond the specified timespan.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2014 21:38:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172330#M6444</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2014-08-06T21:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172331#M6445</link>
      <description>&lt;P&gt;The subsearch only uses two lines produced by calendar, thus is super efficient.  Great lesson about &lt;CODE&gt;makemv&lt;/CODE&gt;.  Not that it matters, but in the interest of minimalism this takes a couple less &lt;CODE&gt;eval&lt;/CODE&gt;s:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| timechart span=1h count&lt;BR /&gt;
| appendpipe [&lt;BR /&gt;
  | stats count&lt;BR /&gt;
  | addinfo&lt;BR /&gt;
  | eval temp=info_min_time."##".info_max_time&lt;BR /&gt;
  | fields temp count&lt;BR /&gt;
  | makemv temp delim="##"&lt;BR /&gt;
  | mvexpand temp &lt;BR /&gt;
  | rename temp as _time&lt;BR /&gt;
] | timechart span=1h max(count) as count&lt;BR /&gt;
| fillnull&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Aug 2014 03:31:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172331#M6445</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2014-08-07T03:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172332#M6446</link>
      <description>&lt;P&gt;In order to create zero values in each time bucket, you need append and stats/eventstats.  I will introduce a slightly more complicated search to demonstrate the full power of this approach: the sum of the events for each value in "field1" every 5 minutes (even if there are no events from up to all but one of the values in "field1"):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearch | bucket span=5m _time | stats sum(events) as events by _time field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Add append, but be wary that the number of events in the subsearch does not expend the subsearch limit:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearch | bucket span=5m _time | stats sum(events) as events by _time field1 | append [yoursearch | bucket span=5m _time | table _time field1 | eventstats values(field1) AS field1 values(_time) AS times | stats count by field1 times | eval events=0 | rename times AS _time] | stats max(events) AS events by _time field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This approach assumes that every _time 5 minute span contains contains data from at least one value in field1.  If this is not the case, then add another data source with values in all time span periods, and then rename the field to field1 at the start of your append, and then remove that value from field1 at the end of your append subsearch.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2015 22:05:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172332#M6446</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-07-12T22:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172333#M6447</link>
      <description>&lt;P&gt;timechart is very unideal for this case.  Try my solution below with append, stats, and eventstats.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2015 22:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172333#M6447</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-07-12T22:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172334#M6448</link>
      <description>&lt;P&gt;Is there a way to do this when I want to split? When I add "by host" to my timechart this answer stops working. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 19:17:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172334#M6448</guid>
      <dc:creator>csendekw</dc:creator>
      <dc:date>2015-10-22T19:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172335#M6449</link>
      <description>&lt;P&gt;try my solution below.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2015 20:10:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172335#M6449</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-10-25T20:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172336#M6450</link>
      <description>&lt;P&gt;I don't understand how to try your solution at all. What is field1? Is that arbitrary? I'm not looking at fields in my search, only event counts. Additionally you state that it only works if there is at least one event  from a value in a field. that statement doesn't even make sense at all to me :(. events from a value? My search is basically (60 minute window):&lt;BR /&gt;
index=blah eventtype=error | timechart span=1m count by host&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 13:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172336#M6450</guid>
      <dc:creator>csendekw</dc:creator>
      <dc:date>2015-10-26T13:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172337#M6451</link>
      <description>&lt;P&gt;This was pretty helpful to get me going, thought I'd share my finished product w/ others if they might find it useful.  What I needed to do was get data for each minutely timebucket in a stats call of mine, but I had multiple fields that I was pivoting on so the solution had to be expanded upon a bit.  Here's what I did:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search |bucket _time span=1m| stats sum(field1) as field1 avg(field2) as field2 by field3 field4 _time| appendpipe [|inputlookup field3_lookup |table field3 | dedup field3 |stats values(field3)  |addinfo | eval temp=info_min_time."##".info_max_time | makemv temp delim="##" | mvexpand temp  | eval _time=temp | timechart span=1m values(field3) as field3 | eval field3=mvjoin(field3,";") | streamstats last(field3) as field3 | makemv delim=";" field3 | mvexpand field3 | eval field1=0 | eval field2=0 | eval field4="possibility1;possibility2;possiblity3" | makemv field4 delim=";"| mvexpand field4]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The lookup contains all possible values for field3, so basically filling out all possible values that could show up in the base stats call, then afterward further down the line not pictured I do an sistats call that gets me everything I want and now has "0" values for time buckets that otherwise wouldn't show up for certain variants of field3 and field4&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 23:35:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172337#M6451</guid>
      <dc:creator>briancronrath</dc:creator>
      <dc:date>2018-02-21T23:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172338#M6452</link>
      <description>&lt;P&gt;This solution worked for me, thank you briancronrath. One thing that I had to do was ad an additional AS with the portion which says&lt;/P&gt;

&lt;P&gt;|stats values(field3) &lt;STRONG&gt;AS field3&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[|inputlookup field3_lookup |table field3 | dedup field3 |stats values(field3) AS field3 |addinfo | eval temp=info_min_time."##".info_max_time | makemv temp delim="##" | mvexpand temp  | eval _time=temp | timechart span=1m values(field3) as field3 | eval field3=mvjoin(field3,";") | streamstats last(field3) as field3 | makemv delim=";" field3 | mvexpand field3 | eval field1=0 | eval field2=0 | eval field4="possibility1;possibility2;possiblity3" | makemv field4 delim=";"| mvexpand field4]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2018 15:43:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/172338#M6452</guid>
      <dc:creator>jbuckner85</dc:creator>
      <dc:date>2018-10-26T15:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/535638#M18425</link>
      <description>&lt;P&gt;Thanks for sharing.&lt;/P&gt;&lt;P&gt;Why is the last | fillnull needed though?&lt;/P&gt;&lt;P&gt;I removed is and the _time bins are still filled with 0 values and interpreted correctly in the dashboard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 11:54:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/535638#M18425</guid>
      <dc:creator>patrickprodoehl</dc:creator>
      <dc:date>2021-01-13T11:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to produce empty time buckets</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/552537#M18831</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;DIV class="p-rich_text_section"&gt;given the below input (4 mins of sample access log data):&lt;/DIV&gt;&lt;PRE&gt;_time,URI,Bytes&lt;BR /&gt;2021-05-18 02:01:00,a,1&lt;BR /&gt;2021-05-18 02:01:00,a,1&lt;BR /&gt;2021-05-18 02:02:00,a,1&lt;BR /&gt;2021-05-18 02:03:00,b,1&lt;BR /&gt;2021-05-18 02:03:00,b,1&lt;BR /&gt;2021-05-18 02:04:00,a,1&lt;/PRE&gt;&lt;DIV class="p-rich_text_section"&gt;assuming a window of 2 mins, i want to perform some computations (average and standard dev of bytes grouped by URI) as below&lt;/DIV&gt;&lt;PRE&gt;source="ds1.csv" host="vgspl11hr" index="sfp" sourcetype="csv"&lt;BR /&gt;| table _time,URI,Bytes&lt;BR /&gt;| timechart span=1m  avg(Bytes) AS avg_bytes, stdev(Bytes) AS std_bytes by URI limit=0&lt;BR /&gt;| fillnull value=""&lt;BR /&gt;| untable _time Measure Value&lt;BR /&gt;| eval Metric=mvindex(split(Measure,": "),0),uri=mvindex(split(Measure,": "),1)&lt;BR /&gt;| fields - Measure&lt;BR /&gt;| eval time_uri=_time."__".uri&lt;BR /&gt;| fields - uri - _time&lt;BR /&gt;| xyseries time_uri Metric Value&lt;BR /&gt;| eval _time=mvindex(split(time_uri,"__"),0),uri=mvindex(split(time_uri,"__"),1)&lt;BR /&gt;| fields - time_uri&lt;/PRE&gt;&lt;DIV class="p-rich_text_section"&gt;with 2-min time window between (5/18/21 2:01:00.000 AM to 5/18/21 2:03:00.000 AM), below is the output:&lt;/DIV&gt;&lt;PRE&gt;_time	            uri	avg_bytes	std_bytes&lt;BR /&gt;2021-05-18 02:01:00	a	1			0&lt;BR /&gt;2021-05-18 02:02:00	a	1			0&lt;/PRE&gt;&lt;DIV class="p-rich_text_section"&gt;So, the timechart performed the computations on the existing URIs in the first 2 mins time window, in that case the URI=a.&lt;BR /&gt;but i want the timechart to consider the existence of the URI = b.&lt;/DIV&gt;&lt;DIV class="p-rich_text_section"&gt;Is there a way to have the timechart consider all the values of the URI in the computation, even if not all of the URI have values in the time window?&lt;/DIV&gt;&lt;DIV class="p-rich_text_section"&gt;I need the output to be as below in the first 2 mins time window:&lt;/DIV&gt;&lt;PRE&gt;_time	            uri	avg_bytes	std_bytes&lt;BR /&gt;2021-05-18 02:01:00	a	1			0&lt;BR /&gt;2021-05-18 02:01:00	b				&lt;BR /&gt;2021-05-18 02:02:00	a	1			0&lt;BR /&gt;2021-05-18 02:02:00	b				&lt;/PRE&gt;&lt;DIV class="p-rich_text_section"&gt;Is that possible?&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 May 2021 08:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-produce-empty-time-buckets/m-p/552537#M18831</guid>
      <dc:creator>nouraali</dc:creator>
      <dc:date>2021-05-21T08:48:21Z</dc:date>
    </item>
  </channel>
</rss>

