<?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 search the top users and compare the usage stats of those users with the previous two days? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279134#M84294</link>
    <description>&lt;P&gt;I am getting results for today and yesterday. For the day before (previous day) you need to append another query with different time range. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=apiUser   earliest=@d latest=now  | stats count(api) AS TodayCount  by userID 
| append [ search  index=apiUser  earliest=-1d@d latest=@d | stats count(api) AS YesterdayCount  by userID] 
| append [ search  index=apiUser  earliest=-2d@d latest=-1d@d | stats count(api) AS PreviousDayCount  by userID]
| stats sum(TodayCount) AS TodayCount sum(YesterdayCount) AS YesterdayCount sum(PreviousDayCount) AS PreviousDayCount by userID| sort by -TodayCount | head 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Dec 2016 20:45:11 GMT</pubDate>
    <dc:creator>nabeel652</dc:creator>
    <dc:date>2016-12-15T20:45:11Z</dc:date>
    <item>
      <title>How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279127#M84287</link>
      <description>&lt;P&gt;I have the search below to pull out the count of users for today &amp;amp; last two days.&lt;BR /&gt;
I want to modify this to pull the top users and compare the usage stats of those users from the previous two days. I tried with the top command, but I guess I am doing something wrong :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=apiUser  earliest=-d@d | eval timeframe=case(_time&amp;gt;relative_time(now(), "@d"), "Today",_timerelative_time(now(), "-1d@d"), "1 days") | chart count(userID) over userID by timeframe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;userID - is the unique user Id of a person using the services &lt;BR /&gt;
api - is the name of api that he is using (one user can call multiple api's &amp;amp; I am interested in his(10 top users) total count for a day)&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 23:02:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279127#M84287</guid>
      <dc:creator>Vicky84</dc:creator>
      <dc:date>2016-12-13T23:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279128#M84288</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=apiUser  earliest=-1d@d | eval timeframe=case(_time&amp;gt;relative_time(now(), "@d"), "Today","Yesterday") | chart count(userID) over userID by timeframe | addtotals | sort 10 -Total 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above search should give you top 10 users, bases on total count for today and yesterday. You can then compare/calculate percentage change based off column Today and Yesterday.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;BR /&gt;
Also try  this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=apiUser  earliest=-1d@d | eval timeframe=case(_time&amp;gt;relative_time(now(), "@d"), "Today","Yesterday") | chart count(userID) over userID by timeframe | sort 0 -Today
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Dec 2016 02:26:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279128#M84288</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-14T02:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279129#M84289</link>
      <description>&lt;P&gt;you need to run the query  twice, once for today's timeframes and once for yesterday's timeframes. then append the two results and use stats to combine both. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=apiUser   earliest=@d latest=now  | stats count(api) AS TodayCount  by userID | append [ search  index=apiUser  earliest=-1d@d latest=@d | stats count(api) AS YesterdayCount  by userID] | stats sum(TodayCount) AS TodayCount sum(YesterdayCount) AS YesterdayCount by userID| sort by -YesterdayCount | head 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can sort by -TodayCount and then select top 10 as well.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 02:37:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279129#M84289</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-14T02:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279130#M84290</link>
      <description>&lt;P&gt;Hi Nabeel, That is fine but I want to use the same userID which was highest today and get the stats from previous day for the SAME userID, to compare the stats from last day&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 23:06:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279130#M84290</guid>
      <dc:creator>Vicky84</dc:creator>
      <dc:date>2016-12-14T23:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279131#M84291</link>
      <description>&lt;P&gt;So when you will sort it by TodayCount and select the top 10 users, YesterdayCount column will be showing their counts from yesterday.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 23:09:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279131#M84291</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-14T23:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279132#M84292</link>
      <description>&lt;P&gt;This will do what you need, I think&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=apiUser   earliest=@d latest=now  | stats count(api) AS TodayCount  by userID | append [ search  index=apiUser  earliest=-1d@d latest=@d | stats count(api) AS YesterdayCount  by userID] | stats sum(TodayCount) AS TodayCount sum(YesterdayCount) AS YesterdayCount by userID| sort by -TodayCount | head 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Dec 2016 23:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279132#M84292</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-14T23:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279133#M84293</link>
      <description>&lt;P&gt;Hi Nabeel,&lt;BR /&gt;
It gives results for today but I don't get any result for yesterday if I use this query, can you suggest if there is a way to do so.&lt;BR /&gt;
My requirement is like :&lt;BR /&gt;
if X &amp;amp; Y are the top api users for today, get their stats for today &amp;amp; compare from last 2 days &lt;BR /&gt;
Report :&lt;BR /&gt;
user (today)    (yesterday) (2days earlier)&lt;BR /&gt;
x       62334       2330           3330&lt;BR /&gt;
y       46646      44444          414442&lt;/P&gt;

&lt;P&gt;So, report will tell X is behaving exceptionally(his today's usage has jumped) while y is a normal usage as his trend has not changed. &lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 18:21:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279133#M84293</guid>
      <dc:creator>Vicky84</dc:creator>
      <dc:date>2016-12-15T18:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279134#M84294</link>
      <description>&lt;P&gt;I am getting results for today and yesterday. For the day before (previous day) you need to append another query with different time range. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=apiUser   earliest=@d latest=now  | stats count(api) AS TodayCount  by userID 
| append [ search  index=apiUser  earliest=-1d@d latest=@d | stats count(api) AS YesterdayCount  by userID] 
| append [ search  index=apiUser  earliest=-2d@d latest=-1d@d | stats count(api) AS PreviousDayCount  by userID]
| stats sum(TodayCount) AS TodayCount sum(YesterdayCount) AS YesterdayCount sum(PreviousDayCount) AS PreviousDayCount by userID| sort by -TodayCount | head 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Dec 2016 20:45:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279134#M84294</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-15T20:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top users and compare the usage stats of those users with the previous two days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279135#M84295</link>
      <description>&lt;P&gt;Hi did it work for you?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 01:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-users-and-compare-the-usage-stats-of-those/m-p/279135#M84295</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-16T01:52:16Z</dc:date>
    </item>
  </channel>
</rss>

