<?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 group events by time after using timechart span? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473651#M133262</link>
    <description>&lt;P&gt;@richgalloway Unfortunately this produces a field with the exact time (hour &amp;amp; minute) when what I'm looking for is just the hour.&lt;/P&gt;

&lt;P&gt;The resulting column should match the hour &lt;CODE&gt;timestamp span=1hr&lt;/CODE&gt; outputs but in the &lt;CODE&gt;"%I:%H%p"&lt;/CODE&gt; format.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Dec 2019 17:03:10 GMT</pubDate>
    <dc:creator>russell120</dc:creator>
    <dc:date>2019-12-31T17:03:10Z</dc:date>
    <item>
      <title>How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473645#M133256</link>
      <description>&lt;P&gt;I'm using the following search with timechart span=1h to show how many events appear by the day and hour:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup my_lookup.csv
|more lines of query
|timechart span=1h count
|rename count as "Number of Items"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This produces a result like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     _time         "Number of Items" 
2019-12-03 15:00            3
2019-12-04 17:00            2
2019-12-05 16:00            2
2019-12-09 17:00            2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What query do I need to show the number of events by just the hour &lt;STRONG&gt;after&lt;/STRONG&gt; I've used &lt;CODE&gt;timechart span=1hr&lt;/CODE&gt;? Below is what I'd like to see:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; hour      "New Count"
03:00PM         2
05:00PM         4
02:00PM         2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473645#M133256</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-12-31T15:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473646#M133257</link>
      <description>&lt;P&gt;To reformat the _time field you can use &lt;CODE&gt;strftime&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...  | timechart span=1h count
| rename count as "Number of Items"
| eval hour=strftime(_time, "%I:%H%p")
| table hour "Number of Items"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please explain how you arrived at the values for "New Count".&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:42:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473646#M133257</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-12-31T15:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473647#M133258</link>
      <description>&lt;P&gt;This might help:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="2019-12-03 15:00:00,3;
2019-12-04 17:00:00,2;
2019-12-05 16:00:00,2;
2019-12-09 17:00:00,2;
2019-12-09 08:00:00,2;
2019-12-08 11:00:00,3;
2019-12-05 11:00:00,1;
2019-12-08 12:00:00,3"
| makemv data delim=";" | mvexpand data | rex field=data "(\s|\n?)(?&amp;lt;data&amp;gt;.*)" | makemv data delim=","
| eval _time=strptime(mvindex(data,0),"%Y-%m-%d %H:%M:%S"),
     numItems=mvindex(data,1)
| fields _time numItems
| eval hourNum=strftime(_time,"%H")
| stats sum(numItems) AS CountByHour by hourNum
| eval hourNum=if(hourNum&amp;gt;12,"0".(hourNum-12).":00PM",hourNum.":00AM")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just for readability, you should consider overriding your count with a name that isn't reserved, like Volume. Also avoid using spaces in field names, although you can do this at the very end for presentation using the &lt;CODE&gt;rename&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;You'll want to add lines 14-16 to your search, minding the field name changes.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473647#M133258</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-12-31T15:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473648#M133259</link>
      <description>&lt;P&gt;Looks like "New Count" is the sum of "Number of Items" for that hour, spanning multiple days.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473648#M133259</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-12-31T15:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473649#M133260</link>
      <description>&lt;P&gt;Try adding this to the end of your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval hour=strftime(_time,"%I:%M%p")
 | fields - _time | table hour *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:45:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473649#M133260</guid>
      <dc:creator>mydog8it</dc:creator>
      <dc:date>2019-12-31T15:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473650#M133261</link>
      <description>&lt;P&gt;@jpolvino You are exactly right. Please give me a moment while I read the solutions.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:50:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473650#M133261</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-12-31T16:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473651#M133262</link>
      <description>&lt;P&gt;@richgalloway Unfortunately this produces a field with the exact time (hour &amp;amp; minute) when what I'm looking for is just the hour.&lt;/P&gt;

&lt;P&gt;The resulting column should match the hour &lt;CODE&gt;timestamp span=1hr&lt;/CODE&gt; outputs but in the &lt;CODE&gt;"%I:%H%p"&lt;/CODE&gt; format.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 17:03:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473651#M133262</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-12-31T17:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to group events by time after using timechart span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473652#M133263</link>
      <description>&lt;P&gt;Ah, this does exactly what I needed. I didn't even think to use &lt;CODE&gt;|stats sum()&lt;/CODE&gt; by the hour. Much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 17:09:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-events-by-time-after-using-timechart-span/m-p/473652#M133263</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-12-31T17:09:23Z</dc:date>
    </item>
  </channel>
</rss>

