<?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: Trending of top 20 errors comparing previous days errors in Security</title>
    <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310718#M12680</link>
    <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=servers sourcetype=json Name= Version= Id=* level=Error OR Critical earliest=-1d@d latest=now 
| eval Period=if(_time&amp;lt;relative_time(now(),"@d"),"Yesterday","Today") 
| chart count over msg by Period 
| sort 20 -Today
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The time range is included in the search inline, which select data for today and yesterday. &lt;BR /&gt;
The output will be top 20 errors based on count of Today. It'll also include column "Yesterday" showing count of same error yesterday.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 20:27:16 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-02-23T20:27:16Z</dc:date>
    <item>
      <title>Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310717#M12679</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a requirement to do a trend of today's top 10 errors and then compare the count of those same top 10 errors from yesterday.&lt;/P&gt;

&lt;P&gt;index=servers sourcetype=json Name=* Version=* Id=* level=Error OR Critical | top limit=20 msg this gives me today's top errors. how do i a write subsearch which will actually give me the count of each error comparing from yesterday.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 19:45:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310717#M12679</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-02-23T19:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310718#M12680</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=servers sourcetype=json Name= Version= Id=* level=Error OR Critical earliest=-1d@d latest=now 
| eval Period=if(_time&amp;lt;relative_time(now(),"@d"),"Yesterday","Today") 
| chart count over msg by Period 
| sort 20 -Today
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The time range is included in the search inline, which select data for today and yesterday. &lt;BR /&gt;
The output will be top 20 errors based on count of Today. It'll also include column "Yesterday" showing count of same error yesterday.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 20:27:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310718#M12680</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-02-23T20:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310719#M12681</link>
      <description>&lt;P&gt;Thanks Man, It works like a champ. Can you explain the logic behind Period=if(_time&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 23:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310719#M12681</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-02-23T23:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310720#M12682</link>
      <description>&lt;P&gt;The Period field is set to value "Yesterday" if they are from yesterday (_time of events is older than midnight today). Its set to "Today" otherwise. The chart command will create columns for each value of field Period with count of events for corresponding msg field.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 00:02:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310720#M12682</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-02-24T00:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310721#M12683</link>
      <description>&lt;P&gt;what change should I introduce in the query if I need for 24 hours window, Like comparison between last 24 hours and 24 hours before that.&lt;/P&gt;

&lt;P&gt;I tried to change the query but numbers were way off.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 02:05:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310721#M12683</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-02-25T02:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310722#M12684</link>
      <description>&lt;P&gt;Also Still trying to understand technically what this statement would do :&lt;/P&gt;

&lt;P&gt;_time &amp;lt; relative_time(now(),"@d")&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:11:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310722#M12684</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2020-09-29T18:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310723#M12685</link>
      <description>&lt;P&gt;@macadminrohit, since there are several cascaded functions in eval. In order to understand you can break down the command to the following first:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;relative_time(now(),"@d")&lt;/CODE&gt;: The &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions#relative_time.28X.2CY.29"&gt;relative_time()&lt;/A&gt; function takes two arguments. First one is the epoch time and second one is the &lt;CODE&gt;snap to time&lt;/CODE&gt;.  In this case it takes the current time using &lt;CODE&gt;now()&lt;/CODE&gt; function and then &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Search/Specifytimemodifiersinyoursearch#Relative_time_modifiers_that_snap_to_a_time"&gt;snaps to&lt;/A&gt; &lt;CODE&gt;the beginning of the day&lt;/CODE&gt; using &lt;CODE&gt;@d&lt;/CODE&gt; which is same as &lt;CODE&gt;-0d@d&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;So, essentially using &lt;CODE&gt;relative_time()&lt;/CODE&gt;, the epoch time for &lt;CODE&gt;current date midnight&lt;/CODE&gt; is set and using &lt;CODE&gt;_time &amp;lt; current date mid night&lt;/CODE&gt; we are able to find yesterday's data.&lt;/P&gt;

&lt;P&gt;To answer your previous query to compare twp windows i.e. last 48 hours - 24 hours and 24 hrs to now you can try something like 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!="INFO" earliest=-48h@h latest=now 
| eval Period=if(_time&amp;lt;relative_time(now(),"-24h@h"),"48 to 24 hrs","24 hrs to now") 
| chart count over component by Period
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Feb 2018 06:00:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310723#M12685</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-02-25T06:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trending of top 20 errors comparing previous days errors</title>
      <link>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310724#M12686</link>
      <description>&lt;P&gt;Perfect Thanks Niket and Somesh&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 21:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Trending-of-top-20-errors-comparing-previous-days-errors/m-p/310724#M12686</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-02-26T21:01:15Z</dc:date>
    </item>
  </channel>
</rss>

