<?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: Count for multiple timeframes in a single query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290773#M87865</link>
    <description>&lt;P&gt;This is a thing of beauty, for which I am extremely grateful and from which I have learned a lot!!! &lt;/P&gt;

&lt;P&gt;Many thanks&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2017 13:52:15 GMT</pubDate>
    <dc:creator>ipicbc</dc:creator>
    <dc:date>2017-03-27T13:52:15Z</dc:date>
    <item>
      <title>Count for multiple timeframes in a single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290770#M87862</link>
      <description>&lt;P&gt;I am looking for a table where each row has the count of a value, in this case errors for each host.  I need 2 value columns, 1 for no. errors in the last day, the other for errors in the last hour.  Maybe a 3rd with errors in the last 10 minutes.  Is there a way that I can have a single query which delivers the output from multiple count statements in a way that I can use them to populate a table?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 08:30:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290770#M87862</guid>
      <dc:creator>ipicbc</dc:creator>
      <dc:date>2017-03-22T08:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Count for multiple timeframes in a single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290771#M87863</link>
      <description>&lt;P&gt;Try this. You will need to add your base search to it, and you will need to change fields if your base search returns more events than only the error ones you are interested in. &lt;/P&gt;

&lt;P&gt;You could do this with &lt;CODE&gt;eventstats&lt;/CODE&gt;, but that is probably more efficient since you are going over the data set multiple times.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;BASE_SEARCH&amp;gt; earliest=-1d 
| eval marker = if(_time &amp;gt;= relative_time(now(), "-10min"), "ten", if(_time &amp;gt;= relative_time(now(), "-1h"), "hour", "day")) 
| chart count over host by marker 
| fillnull value=0 day hour ten 
| eval day = day + ten + hour 
| eval hour = hour + ten
| table host day hour ten
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 11:14:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290771#M87863</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-03-22T11:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Count for multiple timeframes in a single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290772#M87864</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval age = now() - _time | stats count(eval(age&amp;lt;86400)) AS errors_last_24_hours count(eval(age&amp;lt;3600)) AS errors_last_hour count(eval(age&amp;lt;600)) AS errors_last_10_minutes BY host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Mar 2017 05:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290772#M87864</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-25T05:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count for multiple timeframes in a single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290773#M87865</link>
      <description>&lt;P&gt;This is a thing of beauty, for which I am extremely grateful and from which I have learned a lot!!! &lt;/P&gt;

&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 13:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/290773#M87865</guid>
      <dc:creator>ipicbc</dc:creator>
      <dc:date>2017-03-27T13:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Count for multiple timeframes in a single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/549529#M155925</link>
      <description>&lt;P&gt;How to search for today's timeframe from the below,&lt;/P&gt;&lt;P&gt;eval age = now() - _time | stats count(eval(age&amp;lt;86400)) AS errors_last_24_hours count(eval(age&amp;lt;3600)) AS errors_last_hour count(eval(age&amp;lt;600)) AS errors_last_10_minutes BY host&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 20:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-for-multiple-timeframes-in-a-single-query/m-p/549529#M155925</guid>
      <dc:creator>Sab</dc:creator>
      <dc:date>2021-04-27T20:47:24Z</dc:date>
    </item>
  </channel>
</rss>

