<?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 Need every time interval as a row even though the count of records is 0 in that interval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494316#M137814</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am using below query to get the stats o/p of Total, Failure &amp;amp; Failure percent by couple of fields for every 15 min interval over 2 hrs duration.&lt;/P&gt;

&lt;P&gt;index=dte_fios sourcetype=dte2_Fios FT=*FT earliest=04/20/2020:11:00:00 latest=04/20/2020:13:00:00&lt;BR /&gt;
| bin _time span=15m&lt;BR /&gt;
| stats count as Total, count(eval(Error_Code!="0000")) AS Failure by FT,Error_Code,_time&lt;BR /&gt;
| eval Failurepercent=round(Failure/Total*100)&lt;/P&gt;

&lt;P&gt;I am getting O/p as expected in terms of cols like below:&lt;/P&gt;

&lt;P&gt;FT                              Error_Code                _time                                     Total                   Failure                       Failurepercent&lt;BR /&gt;
ALCATEL_FT             8950                   2020-04-20 12:15:00                   10                        10                              100%&lt;BR /&gt;
ALCATEL_FT             8950                   2020-04-20 12:30:00                   10                        5                                50%&lt;BR /&gt;
ALCATEL_FT             8950                   2020-04-20 12:45:00                   10                        10                              100%&lt;/P&gt;

&lt;P&gt;The issue here is if any interval is having 0 records (we do not have row for 11, 11:15 11:30 intervals) is is not showing a row. I need the O/P to give row for every 15min interval and show Total &amp;amp; Failure as 0. I tried to use timechart but I could not get the above o/p format as stats is not working with timehcart.&lt;/P&gt;

&lt;P&gt;Can someone help with the query?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:22:17 GMT</pubDate>
    <dc:creator>poddraj</dc:creator>
    <dc:date>2020-09-30T05:22:17Z</dc:date>
    <item>
      <title>Need every time interval as a row even though the count of records is 0 in that interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494316#M137814</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am using below query to get the stats o/p of Total, Failure &amp;amp; Failure percent by couple of fields for every 15 min interval over 2 hrs duration.&lt;/P&gt;

&lt;P&gt;index=dte_fios sourcetype=dte2_Fios FT=*FT earliest=04/20/2020:11:00:00 latest=04/20/2020:13:00:00&lt;BR /&gt;
| bin _time span=15m&lt;BR /&gt;
| stats count as Total, count(eval(Error_Code!="0000")) AS Failure by FT,Error_Code,_time&lt;BR /&gt;
| eval Failurepercent=round(Failure/Total*100)&lt;/P&gt;

&lt;P&gt;I am getting O/p as expected in terms of cols like below:&lt;/P&gt;

&lt;P&gt;FT                              Error_Code                _time                                     Total                   Failure                       Failurepercent&lt;BR /&gt;
ALCATEL_FT             8950                   2020-04-20 12:15:00                   10                        10                              100%&lt;BR /&gt;
ALCATEL_FT             8950                   2020-04-20 12:30:00                   10                        5                                50%&lt;BR /&gt;
ALCATEL_FT             8950                   2020-04-20 12:45:00                   10                        10                              100%&lt;/P&gt;

&lt;P&gt;The issue here is if any interval is having 0 records (we do not have row for 11, 11:15 11:30 intervals) is is not showing a row. I need the O/P to give row for every 15min interval and show Total &amp;amp; Failure as 0. I tried to use timechart but I could not get the above o/p format as stats is not working with timehcart.&lt;/P&gt;

&lt;P&gt;Can someone help with the query?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:22:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494316#M137814</guid>
      <dc:creator>poddraj</dc:creator>
      <dc:date>2020-09-30T05:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need every time interval as a row even though the count of records is 0 in that interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494317#M137815</link>
      <description>&lt;P&gt;Please share the query that uses &lt;CODE&gt;timechart&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 12:50:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494317#M137815</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-06T12:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need every time interval as a row even though the count of records is 0 in that interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494318#M137816</link>
      <description>&lt;P&gt;Hi poddraj,&lt;/P&gt;

&lt;P&gt;first, you create an "empty table" with all possible time slots:&lt;BR /&gt;
&lt;CODE&gt;| gentimes [|makeresults|addinfo|eval start=strftime(info_min_time,"%m/%d/%Y:%H:%M:%S")| return start]  [|makeresults|addinfo|eval end=strftime(info_max_time,"%m/%d/%Y:%H:%M:%S")| return end] increment=15min&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;the next will create some demo devices. In your query you could use a | join [|inputlookup] to create one line per time per device&lt;BR /&gt;
&lt;CODE&gt;| eval FT="deviceA,deviceB,deviceC" | makemv delim="," FT | mvexpand FT&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;the next step is to create one line per possible error code per device per time:&lt;BR /&gt;
&lt;CODE&gt;| eval Error_Code="8950,2166,7633" | makemv delim="," Error_Code |mvexpand Error_Code&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and finally initialize the counter with 0 and rename the time:&lt;BR /&gt;
&lt;CODE&gt;| eval Failure=0, _time=starttime&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If you concatenate all in sequence, you will get a table like this:&lt;BR /&gt;
'2020-05-06 12:00:00' 'DeviceA' 'Error1' 0&lt;BR /&gt;
'2020-05-06 12:00:00' 'DeviceA' 'Error2' 0&lt;BR /&gt;
'2020-05-06 12:00:00' 'DeviceA' 'Error3' 0&lt;BR /&gt;
'2020-05-06 12:00:00' 'DeviceB' 'Error1' 0&lt;BR /&gt;
...&lt;BR /&gt;
'2020-05-06 12:15:00' 'DeviceC' 'Error3' 0&lt;/P&gt;

&lt;P&gt;Now, you can append your query:&lt;BR /&gt;
&lt;CODE&gt;| append [search index=dte_fios sourcetype=dte2_Fios FT=*FT earliest=04/20/2020:11:00:00 latest=04/20/2020:13:00:00&lt;BR /&gt;
| bin _time span=15m | eval Failure=if(Error_Code!="0000",1,0)]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The resulting table has your query results mixed into the "empty frame of no failures". Finally you can run your stats and since you have a result for every possible time value in your query range, you will get a perfectly filled result table&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| stats count as Total, sum(Failure) AS Failure by FT,Error_Code,_time&lt;BR /&gt;
| eval Failurepercent=round(Failure/Total*100)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Hope it helps&lt;BR /&gt;
Oliver&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 13:26:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494318#M137816</guid>
      <dc:creator>ololdach</dc:creator>
      <dc:date>2020-05-06T13:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need every time interval as a row even though the count of records is 0 in that interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494319#M137817</link>
      <description>&lt;P&gt;Based on your inputs I have used below query but it is not creating rows for every 15 min interval.&lt;/P&gt;

&lt;P&gt;| gentimes start=04/20/2020:11:00:00 end=04/20/2020:13:00:00 increment=15m  | rename starttime as _time &lt;BR /&gt;
 | fields _time &lt;BR /&gt;
| lookup ftthresholdlkp FT&lt;BR /&gt;
| eval FT=FT | makemv delim="," FT | mvexpand FT |  eval Failure=0&lt;BR /&gt;
|  append [search index=dte_fios sourcetype=dte2_Fios FT=*FT earliest=04/20/2020:11:00:00 latest=04/20/2020:13:00:00 | bin _time span=15m | eval Failure=if(Error_Code!="0000",1,0)]&lt;BR /&gt;
| stats count(WPID) as Total, sum(Failure) AS Failure by FT,_time | eval Failurepercent=if(Failure=0,0,round(Failure/Total*100))&lt;/P&gt;

&lt;P&gt;Instead of lookup if I give FT="ALCATEL_FT,HNM_FT,GWR_FT" then I am getting rows for these FT's for every 15 min interval with 0 Total,Failure counts&lt;/P&gt;

&lt;P&gt;I am doing anything wrong in the join?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:22:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494319#M137817</guid>
      <dc:creator>poddraj</dc:creator>
      <dc:date>2020-09-30T05:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need every time interval as a row even though the count of records is 0 in that interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494320#M137818</link>
      <description>&lt;P&gt;Hi poddraj, when I don't get the expected result, I copy the whole query to a scratchpad and execute it step by step, adding one | at a time until I see the step that delivers unexpected results.  Just executing the gentimes, rename and fields gives you exactly the expected time intervals. The lookup seems wrong, because what you ask Splunk to do is: Take the lookup by the name ftthresholdlkp and match on the field FT. You don't have a field FT to match on, the only field you have at that point is _time. Create your lookup table like this:&lt;BR /&gt;
"devicetype","FT"&lt;BR /&gt;
"FT","DeviceA"&lt;BR /&gt;
"FT","DeviceB"&lt;BR /&gt;
...&lt;BR /&gt;
"FT","DeviceX"&lt;BR /&gt;
Do your lookup like this: &lt;CODE&gt;| eval devicetype="FT" | lookup ftthresholdlkp devicetype OUTPUT FT&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;HiH&lt;BR /&gt;
Oliver&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 11:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-every-time-interval-as-a-row-even-though-the-count-of/m-p/494320#M137818</guid>
      <dc:creator>ololdach</dc:creator>
      <dc:date>2020-05-07T11:41:23Z</dc:date>
    </item>
  </channel>
</rss>

