<?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 can i get details with both span 10m and 30 m with dedup _time. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310540#M93131</link>
    <description>&lt;P&gt;Okay, without understanding the underlying data, and what your use case is, your code doesn't make a lot of sense to me.  &lt;CODE&gt;dedup&lt;/CODE&gt; is going to give you the first record it encounters for each &lt;CODE&gt;_time&lt;/CODE&gt; group, which will be the very latest record for each &lt;CODE&gt;_time&lt;/CODE&gt; group, and then you want to throw away all &lt;CODE&gt;_time&lt;/CODE&gt; groups that do not have a zero &lt;CODE&gt;Value&lt;/CODE&gt; at the end of their ten-minute &lt;CODE&gt;_time&lt;/CODE&gt; period?&lt;/P&gt;

&lt;P&gt;If so, then this accomplishes the same thing&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| bin _time span=10m 
| stats latest(Value) as Value by _time Tag
| where Value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is, once you throw away non-zero values, it doesn't make any sense to group the remaining records into 30 minute increments, unless there are three 0 records in that time frame.  That would look like this -  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| table _time Tag Value 
| bin _time span=10m 
| bin _time as Time30 span=30m 
| dedup _time
| where Value=0
| eventstats count as Count30 by Time30
| eval _time=if(Count30=3,Time30,_time)
| dedup _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But in this case, you haven't accounted for the potential difference between records (A) that happen to be at 9:30 but represent only 10 minutes because Value was not zero at 9:40 and 9:50, and records (B) that happen at 9:30 and represent a half hour of 0.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;I suspect that what you really want to know is what periods you have received no activity.  For that, you need a different strategy.  This one here will work if you can be assured there will be records in each ten minute time period, and some of those records will have zero values...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| table _time Tag Value 
| bin _time as StartTime span=10m 
| stats max(Value) as Value by StartTime Tag
| rename COMMENT as "Above gets us the highest Value in each ten-minute period, and the StartTime"

| rename COMMENT as "Now we kill non-zero periods, and calculate the EndTime"
| where Value=0
| eval EndTime=Time+600

| rename COMMENT as "This combines each half-hour period if it is three ten-minute periods of zero activity"
| bin Time as Time30 span=30m 
| eventstats count as Count30 max(EndTime) as End30 by Time30
| eval StartTime=if(Count30=3,Time30,StartTime)
| eval EndTime=if(Count30=3,End30,EndTime)
| dedup StartTime


| rename COMMENT as "And now we format our output Start and EndTime"
| eval StartTime=strftime(StartTime,"%Y-%m-%d %H:%M:%S")
| eval EndTime=strftime(EndTime,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you can't be sure that there will be records in each &lt;CODE&gt;_time&lt;/CODE&gt; period, then alter the first section to add dummy records with an &lt;CODE&gt;appendpipe&lt;/CODE&gt; as follows...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| table _time Tag Value 
| bin _time as StartTime span=10m

| rename COMMENT as "Add an extra zero record for each time period, then take the highest Value for each time period."
| appendpipe [| stats min(StartTime) as FirstTime max(StartTime) as LastTime by Tag | eval StartTime=mvrange(FirstTime,LastTime,600) | table StartTime Tag | mvexpand StartTime | eval Value = 0] 
| stats max(Value) as Value by StartTime Tag
| rename COMMENT as "Above gets us the highest Value in each ten-minute period, and the StartTime"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Jul 2017 15:42:26 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-07-12T15:42:26Z</dc:date>
    <item>
      <title>how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310538#M93129</link>
      <description>&lt;P&gt;I have one Search Query . (index=indexname earliest=1499819400 latest=1499848200 | where Tag="Tagname" |bin _time  span=10m    | dedup _time|table _time Tag Value | where Value=0). &lt;BR /&gt;
this is displaying values like this&lt;BR /&gt;
     _time                  count&lt;BR /&gt;
 7/12/2017 11:00   0&lt;BR /&gt;
7/12/2017  11:10   0&lt;BR /&gt;
7/12/2017  11:20   0&lt;BR /&gt;
7/12/2017   11:30   0&lt;BR /&gt;
7/12/2017    11:40   0&lt;BR /&gt;
But I want output like this  (first 30 mins at a time then ten mins)&lt;BR /&gt;
  _time                  count&lt;BR /&gt;
 7/12/2017 11:00   0&lt;BR /&gt;
7/12/2017  11:30   0&lt;BR /&gt;
7/12/2017  11:40   0&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:14:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310538#M93129</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-07-12T11:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310539#M93130</link>
      <description>&lt;P&gt;Are you saying you want the results for every half hour up to the end of the last half hour increment, and then every ten minutes after that?   So, the 11:30 record is actually 11:30-40 and the 11:40 is 11:40-50?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 15:07:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310539#M93130</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-12T15:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310540#M93131</link>
      <description>&lt;P&gt;Okay, without understanding the underlying data, and what your use case is, your code doesn't make a lot of sense to me.  &lt;CODE&gt;dedup&lt;/CODE&gt; is going to give you the first record it encounters for each &lt;CODE&gt;_time&lt;/CODE&gt; group, which will be the very latest record for each &lt;CODE&gt;_time&lt;/CODE&gt; group, and then you want to throw away all &lt;CODE&gt;_time&lt;/CODE&gt; groups that do not have a zero &lt;CODE&gt;Value&lt;/CODE&gt; at the end of their ten-minute &lt;CODE&gt;_time&lt;/CODE&gt; period?&lt;/P&gt;

&lt;P&gt;If so, then this accomplishes the same thing&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| bin _time span=10m 
| stats latest(Value) as Value by _time Tag
| where Value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is, once you throw away non-zero values, it doesn't make any sense to group the remaining records into 30 minute increments, unless there are three 0 records in that time frame.  That would look like this -  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| table _time Tag Value 
| bin _time span=10m 
| bin _time as Time30 span=30m 
| dedup _time
| where Value=0
| eventstats count as Count30 by Time30
| eval _time=if(Count30=3,Time30,_time)
| dedup _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But in this case, you haven't accounted for the potential difference between records (A) that happen to be at 9:30 but represent only 10 minutes because Value was not zero at 9:40 and 9:50, and records (B) that happen at 9:30 and represent a half hour of 0.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;I suspect that what you really want to know is what periods you have received no activity.  For that, you need a different strategy.  This one here will work if you can be assured there will be records in each ten minute time period, and some of those records will have zero values...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| table _time Tag Value 
| bin _time as StartTime span=10m 
| stats max(Value) as Value by StartTime Tag
| rename COMMENT as "Above gets us the highest Value in each ten-minute period, and the StartTime"

| rename COMMENT as "Now we kill non-zero periods, and calculate the EndTime"
| where Value=0
| eval EndTime=Time+600

| rename COMMENT as "This combines each half-hour period if it is three ten-minute periods of zero activity"
| bin Time as Time30 span=30m 
| eventstats count as Count30 max(EndTime) as End30 by Time30
| eval StartTime=if(Count30=3,Time30,StartTime)
| eval EndTime=if(Count30=3,End30,EndTime)
| dedup StartTime


| rename COMMENT as "And now we format our output Start and EndTime"
| eval StartTime=strftime(StartTime,"%Y-%m-%d %H:%M:%S")
| eval EndTime=strftime(EndTime,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you can't be sure that there will be records in each &lt;CODE&gt;_time&lt;/CODE&gt; period, then alter the first section to add dummy records with an &lt;CODE&gt;appendpipe&lt;/CODE&gt; as follows...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
| table _time Tag Value 
| bin _time as StartTime span=10m

| rename COMMENT as "Add an extra zero record for each time period, then take the highest Value for each time period."
| appendpipe [| stats min(StartTime) as FirstTime max(StartTime) as LastTime by Tag | eval StartTime=mvrange(FirstTime,LastTime,600) | table StartTime Tag | mvexpand StartTime | eval Value = 0] 
| stats max(Value) as Value by StartTime Tag
| rename COMMENT as "Above gets us the highest Value in each ten-minute period, and the StartTime"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 15:42:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310540#M93131</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-12T15:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310541#M93132</link>
      <description>&lt;P&gt;Hai Dalnis thanks for replay.&lt;/P&gt;

&lt;P&gt;What i Need is i want machine which value is zero for particular epoch values. &lt;BR /&gt;
if machine value value is zero for ten minutes then print that time like&lt;BR /&gt;&lt;BR /&gt;
_time                    count&lt;BR /&gt;
7/12/2017 11:00 0&lt;BR /&gt;
7/12/2017 11:10 0&lt;/P&gt;

&lt;P&gt;this means my machine value is zero for 11:00 to 11:10 .&lt;/P&gt;

&lt;P&gt;then if my machine value is zero for thirty minutes    then print time like this&lt;/P&gt;

&lt;P&gt;_time                     count&lt;BR /&gt;
7/12/2017 11:30 0&lt;BR /&gt;
7/12/2017 12 :00 0&lt;/P&gt;

&lt;P&gt;So finally what i want is which timeperiod my machine value is zero?&lt;/P&gt;

&lt;P&gt;i have wrote one query( (index=indexname earliest=1499819400 latest=1499848200 | where Tag="Tagname" |bin _time span=10m | dedup _time|table _time Tag Value | where Value=0). ) it gives  output like this &lt;/P&gt;

&lt;P&gt;_time                     Value&lt;BR /&gt;
7/12/2017 11:30    0&lt;BR /&gt;
7/12/2017 11 :40   0&lt;BR /&gt;
7/12/2017 11 :50   0&lt;BR /&gt;&lt;BR /&gt;
7/12/2017 12 :00   0&lt;BR /&gt;
7/12/2017 11:00    0&lt;BR /&gt;
7/12/2017 11:10    0&lt;/P&gt;

&lt;P&gt;but i want like this  &lt;/P&gt;

&lt;P&gt;_time                     Value&lt;BR /&gt;
7/12/2017 11:30    0&lt;BR /&gt;
7/12/2017 12 :00   0&lt;BR /&gt;
7/12/2017 11:00    0&lt;BR /&gt;
7/12/2017 11:10    0&lt;/P&gt;

&lt;P&gt;my machine value is zero for thirty minutes so it displays 11:30 to 12:00 Value 0&lt;BR /&gt;
my machine value is zero for ten minutes so it displays 11:00 to 11:10 Value 0&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 06:16:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310541#M93132</guid>
      <dc:creator>ajayabburi508</dc:creator>
      <dc:date>2017-07-13T06:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310542#M93133</link>
      <description>&lt;P&gt;hai Bro  I want  when the value of machine is zero &lt;/P&gt;

&lt;P&gt;if machine value is zero for 30 mins i want   time stamp of that 30 mins with Value.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 08:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310542#M93133</guid>
      <dc:creator>ajayabburi508</dc:creator>
      <dc:date>2017-07-13T08:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310543#M93134</link>
      <description>&lt;P&gt;i have wrote one query( (index=indexname earliest=1499819400 latest=1499848200 | where Tag="Tagname" |bin _time span=10m | dedup _time|table _time Tag Value | where Value=0). ) it gives output like this&lt;/P&gt;

&lt;P&gt;_time Value&lt;BR /&gt;
7/12/2017 11:30 0&lt;BR /&gt;
7/12/2017 11 :40 0&lt;BR /&gt;
7/12/2017 11 :50 0 &lt;BR /&gt;
7/12/2017 12 :00 0&lt;BR /&gt;
7/12/2017 11:00 0&lt;BR /&gt;
7/12/2017 11:10 0&lt;/P&gt;

&lt;P&gt;but i want like this&lt;/P&gt;

&lt;P&gt;_time Value&lt;BR /&gt;
7/12/2017 11:30 0&lt;BR /&gt;
7/12/2017 12 :00 0&lt;BR /&gt;
7/12/2017 11:00 0&lt;BR /&gt;
7/12/2017 11:10 0&lt;/P&gt;

&lt;P&gt;my machine value is zero for thirty minutes so it displays 11:30 to 12:00 Value 0&lt;BR /&gt;
my machine value is zero for ten minutes so it displays 11:00 to 11:10 Value 0&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 13:45:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310543#M93134</guid>
      <dc:creator>ajayabburi508</dc:creator>
      <dc:date>2017-07-14T13:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get details with both span 10m and 30 m with dedup _time.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310544#M93135</link>
      <description>&lt;P&gt;@ajayabburi508  - Did you get this solved? The code that we gave you on July 12 would do all that for you.  It will get the start and end times of zero values for each 10-minute period by Tag, and group any sets of 3 into 30-minute periods.  &lt;/P&gt;

&lt;P&gt;Here it is in order and formatted for easy reading.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname earliest=1499819400 latest=1499848200 Tag="Tagname"
 | table _time Tag Value 
 | bin _time as StartTime span=10m 

 | rename COMMENT as "Add an extra zero record for each time period, then take the highest Value for each time period."
 | appendpipe 
    [| stats min(StartTime) as FirstTime max(StartTime) as LastTime by Tag 
     | eval StartTime=mvrange(FirstTime,LastTime,600) 
     | table StartTime Tag 
     | mvexpand StartTime 
     | eval Value = 0
     ] 
 | stats max(Value) as Value by StartTime Tag

 | rename COMMENT as "Above gets us the highest Value in each ten-minute period, and the StartTime"
 | rename COMMENT as "Now we kill non-zero periods, and calculate the EndTime"
 | where Value=0
 | eval EndTime=Time+600

 | rename COMMENT as "This combines each half-hour period if it is three ten-minute periods of zero activity"
 | bin Time as Time30 span=30m 
 | eventstats count as Count30 max(EndTime) as End30 by Time30
 | eval StartTime=if(Count30=3,Time30,StartTime)
 | eval EndTime=if(Count30=3,End30,EndTime)
 | dedup StartTime

 | rename COMMENT as "And now we format our output Start and EndTime"
 | eval StartTime=strftime(StartTime,"%Y-%m-%d %H:%M:%S")
 | eval EndTime=strftime(EndTime,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Oct 2017 23:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-i-get-details-with-both-span-10m-and-30-m-with-dedup/m-p/310544#M93135</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-03T23:30:26Z</dc:date>
    </item>
  </channel>
</rss>

