<?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: Fast searches for a count of events in various ways in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448606#M127092</link>
    <description>&lt;P&gt;what is the problem you are trying to solve?&lt;BR /&gt;
how about the &lt;CODE&gt;| metadata&lt;/CODE&gt; command?&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Metadata"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Metadata&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Feb 2019 22:40:33 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2019-02-07T22:40:33Z</dc:date>
    <item>
      <title>Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448605#M127091</link>
      <description>&lt;P&gt;I've been looking for ways to get fast results for inquiries about the number of events for:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;All indexes&lt;/LI&gt;
&lt;LI&gt;One index&lt;/LI&gt;
&lt;LI&gt;One sourcetype&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;And for #2 by sourcetype and for #3 by index.&lt;/P&gt;

&lt;P&gt;Here are the ideas I've come up with, and I thought I'd share them, plus give a Splunk Answer that others can add to. If you have something clever in this general area (that's fast) please share it here.&lt;/P&gt;

&lt;P&gt;Count of events for an index or across all of them with eventcount:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventcount summarize=false index=winevent_index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There is no way to restrict it to a particular sourcetype or source,&lt;BR /&gt;
and the Time Picker has no effect on it -- It counts all events in&lt;BR /&gt;
an index for all time.&lt;/P&gt;

&lt;P&gt;Here is how to look at all the non-internal indexes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventcount summarize=false index=* report_size=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Similar search with tstats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=* groupby index,_time span=1d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does respect the Time Picker, so if you do last 7 days you&lt;BR /&gt;
get a count for each index, for each day.&lt;/P&gt;

&lt;P&gt;This gives the count of events for one index, with Time Picker set to Week to date:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=winevent_dc_index groupby index,_time span=1d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;index                   _time           count&lt;BR /&gt;
winevent_dc_index       2019-02-03      7765708&lt;BR /&gt;
winevent_dc_index       2019-02-04      9837331&lt;BR /&gt;
winevent_dc_index       2019-02-05      10624149&lt;BR /&gt;
winevent_dc_index       2019-02-06      10198089&lt;BR /&gt;
winevent_dc_index       2019-02-07      5475228&lt;/P&gt;

&lt;P&gt;But I hadn't been able to figure this out for a sourcetype-based search&lt;BR /&gt;
until today. This works great on the main index, which has lots of sourcetypes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=main groupby index,sourcetype,_time span=1d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whereas this search provides the count for a particular sourcetype, by index, by day:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where sourcetype=syslog groupby index,sourcetype,_time span=1d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I finally decided that I'd like to see Events Per Second for all sourcetypes averaged over a given period. I'm using Last  7 days with this:&lt;/P&gt;

&lt;P&gt;Here is a search that provides the EPS number per sourcetype over 7 days for all sourcetypes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats min(_time) as earliest_event max(_time) As mostRecent_event count where sourcetype=* NOT index=os by sourcetype
| eval elapsedTime = mostRecent_event - earliest_event, EPS = tostring(count / elapsedTime, "commas")
| convert ctime(earliest_event), ctime(mostRecent_event)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But, for something like syslog (which is so generic) this search is better because I can tell by index and host what the syslogs are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats min(_time) as earliest_event max(_time) As mostRecent_event count where sourcetype=syslog by index host 
| eval elapsedTime = mostRecent_event - earliest_event, EPS = tostring(count / elapsedTime, "commas")
| convert ctime(earliest_event), ctime(mostRecent_event)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:06:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448605#M127091</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2020-09-29T23:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448606#M127092</link>
      <description>&lt;P&gt;what is the problem you are trying to solve?&lt;BR /&gt;
how about the &lt;CODE&gt;| metadata&lt;/CODE&gt; command?&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Metadata"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Metadata&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 22:40:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448606#M127092</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-02-07T22:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448607#M127093</link>
      <description>&lt;P&gt;I'm putting together a list of the size of the log data for each sourcetype (that's already done) and now I'm adding a column to it that will reflect average EPS. So I could take events in 24 hours and divide by 86400 or take it for a week and divide by 604,800, for example.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 22:54:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448607#M127093</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2019-02-07T22:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448608#M127094</link>
      <description>&lt;P&gt;metadata works fine as well. It seems to not be accurate for anything but All Time because of the way it works with buckets. So if you say Last 7 Days it might return last 9, for example.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:15:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448608#M127094</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2019-02-07T23:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448609#M127095</link>
      <description>&lt;P&gt;like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count as event_count where index=yourIndex by sourcetype _time span=1s
| timechart span=1s max(event_count) as events_per_sec by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count as event_count where index=main by sourcetype _time span=1d
| eval events_per_sec_day = round(event_count / 84600, 2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448609#M127095</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-02-07T23:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448610#M127096</link>
      <description>&lt;P&gt;I liked the second one of these two the best.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 17:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448610#M127096</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2019-02-08T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448611#M127097</link>
      <description>&lt;P&gt;@wrangler2x  very good, converting to an answer&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 18:01:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448611#M127097</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-02-08T18:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448612#M127098</link>
      <description>&lt;P&gt;You seem to have worked this all the way through.  You have not asked a question for us to help you solve. ???&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 21:02:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448612#M127098</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-08T21:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Fast searches for a count of events in various ways</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448613#M127099</link>
      <description>&lt;P&gt;Those last two searches with tstats are my best shot at getting the results I was looking for, and they seem to do the job, as well as being fast. I was hoping that others would offer suggestions I had not thought of, and that I might learn something new, and also I wanted to share what I had figured-out.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 19:33:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fast-searches-for-a-count-of-events-in-various-ways/m-p/448613#M127099</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2019-02-12T19:33:00Z</dc:date>
    </item>
  </channel>
</rss>

