<?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: Display last 8 hours from now () ..? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381914#M167534</link>
    <description>&lt;P&gt;@harishalipaka do u wnt to use this in search or dashboard?&lt;BR /&gt;
Also what is the logic for picking 30 min instead of 31 if the current time is 31 minute?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 09:11:03 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-09-14T09:11:03Z</dc:date>
    <item>
      <title>Display last 8 hours from now () ..?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381913#M167533</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;i want to display the last 8 hours of data with 1 hour different without any index or kv table .like &lt;CODE&gt;makeresults&lt;/CODE&gt; or &lt;CODE&gt;gentimes&lt;/CODE&gt;&lt;BR /&gt;
 Eg:- &lt;STRONG&gt;suppose now time is "2018-09-14 13:31:42"&lt;/STRONG&gt; `&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults |eval current=now() | timechart span=1h count as duration.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;i want to display like below&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;time&lt;/STRONG&gt;&lt;BR /&gt;
13:30&lt;BR /&gt;
12:30&lt;BR /&gt;
11:30&lt;BR /&gt;
10:30&lt;BR /&gt;
09:30&lt;BR /&gt;
08:30&lt;BR /&gt;
07:30&lt;BR /&gt;
06:30&lt;/P&gt;

&lt;P&gt;ThanQ in advance &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 08:06:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381913#M167533</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2018-09-14T08:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Display last 8 hours from now () ..?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381914#M167534</link>
      <description>&lt;P&gt;@harishalipaka do u wnt to use this in search or dashboard?&lt;BR /&gt;
Also what is the logic for picking 30 min instead of 31 if the current time is 31 minute?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 09:11:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381914#M167534</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-09-14T09:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Display last 8 hours from now () ..?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381915#M167535</link>
      <description>&lt;P&gt;@harishalipaka,&lt;/P&gt;

&lt;P&gt;Does it work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=8|eval diff=1|accum diff as diff|eval diff=(diff-1)*3600
|eval _time=strftime(_time-diff,"%H:%M")|fields - diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 10:56:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381915#M167535</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-09-14T10:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Display last 8 hours from now () ..?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381916#M167536</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval time=mvrange(relative_time(now(),"-8h"), now(),1800) | table time | mvexpand time | rename time as _time | timechart span=30m count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval time=mvrange(relative_time(now(),"-8h"), now(),1800) | table time | mvexpand time | rename time as _time | timechart span=30m count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 14:02:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381916#M167536</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-09-14T14:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Display last 8 hours from now () ..?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381917#M167537</link>
      <description>&lt;P&gt;@harishalipaka, try the following run anywhere example based on Splunk's _internal index&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd log_level=ERROR
| timechart span=1h count as Error 
| append
    [| makeresults 
    | addinfo 
    | eval Time=info_max_time.",".info_min_time 
    | fields Time 
    | makemv Time delim="," 
    | mvexpand Time 
    | rename Time as _time 
    | timechart span=1h count(somefieldthatdoesnotexist) as Error] 
| dedup _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The sub-query inside &lt;CODE&gt;append&lt;/CODE&gt; creates dummy rows for each hour provided the Time Range selected for query is &lt;CODE&gt;Last 8 hours&lt;/CODE&gt; i.e. &lt;CODE&gt;earliest=-8h and latest=now&lt;/CODE&gt;. Final dedup returns non-zero counts returned by main search if they are present or else displays the 0 count from second search for last 8 hours.&lt;/P&gt;

&lt;P&gt;You can test the second condition by changing base search from &lt;CODE&gt;log_level=ERROR&lt;/CODE&gt; to &lt;CODE&gt;log_level=ERROR1&lt;/CODE&gt; which does not exist. Instead of showing &lt;CODE&gt;No results Found&lt;/CODE&gt; it will show 0 count for last 8 hours.&lt;/P&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Sat, 15 Sep 2018 08:51:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-last-8-hours-from-now/m-p/381917#M167537</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-09-15T08:51:01Z</dc:date>
    </item>
  </channel>
</rss>

