<?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: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158170#M44577</link>
    <description>&lt;P&gt;does the second search above do what you're seeking here?&lt;/P&gt;</description>
    <pubDate>Wed, 25 Feb 2015 04:09:04 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2015-02-25T04:09:04Z</dc:date>
    <item>
      <title>Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158165#M44572</link>
      <description>&lt;P&gt;I am trying to display errors from the last 24 hours that have NOT happened in the last 7 days. I only want to see the "new" errors. &lt;/P&gt;

&lt;P&gt;When I run this search, it will compare the two time periods and only removes the errors that happened at both times. So it will display the new errors and the old ones. Any help would be greatly appreciated!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|set diff [search sourcetype=Apps (Hosted="A" OR Hosted="B") earliest=-7d@d latest=-1d@d sub_source="'C'" sub_origin="'D'" |stats count by error, msg, program |table error, msg, program] [search sourcetype=Apps (Hosted="A" OR Hosted="B") earliest=-1d@d latest=@m sub_source="'C'" sub_origin="'D'" |stats count by error, msg, program | table error, msg, program] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Feb 2015 18:55:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158165#M44572</guid>
      <dc:creator>natefly5</dc:creator>
      <dc:date>2015-02-23T18:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158166#M44573</link>
      <description>&lt;P&gt;Why not this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=Apps (Hosted="A" OR Hosted="B") earliest=-1d@d latest=@m sub_source="'C'" sub_origin="'D'" 
NOT [search sourcetype=Apps (Hosted="A" OR Hosted="B") earliest=-7d@d latest=-1d@d sub_source="'C'" sub_origin="'D'" |stats count by error, msg, program |table error, msg, program] 
|stats count by error, msg, program | table error, msg, program
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Feb 2015 20:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158166#M44573</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-02-23T20:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158167#M44574</link>
      <description>&lt;P&gt;Add an eval to both sets that identifies one set as the new and one as the old, and just add a where eval="new". Like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|set diff [search sourcetype=Apps (Hosted="A" OR Hosted="B") earliest=-7d@d latest=-1d@d sub_source="'C'" sub_origin="'D'" |stats count by error, msg, program |table error, msg, program | eval label="old"] [search sourcetype=Apps (Hosted="A" OR Hosted="B") earliest=-1d@d latest=@m sub_source="'C'" sub_origin="'D'" |stats count by error, msg, program | table error, msg, program | eval label="new"] | search label="new"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Feb 2015 20:14:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158167#M44574</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2015-02-23T20:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158168#M44575</link>
      <description>&lt;P&gt;This is just a thought, but's let's try this without a subsearch or the set command at all..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-7d@d latest=@m sourcetype=Apps (Hosted="A" OR Hosted="B")  sub_source="'C'" sub_origin="'D'" 
| addinfo
| eval older_than_24 = if( _time &amp;lt; (info_max_time - 86400),1,0)
| stats max(older_than_24) as older_than_24, count by error, msg, program 
| search older_than_24=0
| table error, msg, program
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Or we can try this, which is similar but gives you count of errors in the last 24 hours.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-7d@d latest=@m sourcetype=Apps (Hosted="A" OR Hosted="B")  sub_source="'C'" sub_origin="'D'" 
| addinfo
| eval older_than_24 = if( _time &amp;lt; (info_max_time - 86400),1,0)
| stats count(eval(_time &amp;lt; (info_max_time - 86400))) as  count_older_than_24, count(eval(_time &amp;gt;= (info_max_time - 86400))) as count_last_24 by error, msg, program 
| search count_older_than_24=0
| table error, msg, program
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Feb 2015 04:54:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158168#M44575</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2015-02-24T04:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158169#M44576</link>
      <description>&lt;P&gt;Thank you! This works perfectly. My follow up question is very basic but how can I add a count to show how many times each type of error has happened in the last 24 hours? Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2015 19:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158169#M44576</guid>
      <dc:creator>natefly5</dc:creator>
      <dc:date>2015-02-24T19:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158170#M44577</link>
      <description>&lt;P&gt;does the second search above do what you're seeking here?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2015 04:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158170#M44577</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2015-02-25T04:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158171#M44578</link>
      <description>&lt;P&gt;Yes it works, thanks a lot for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2015 14:28:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158171#M44578</guid>
      <dc:creator>natefly5</dc:creator>
      <dc:date>2015-03-03T14:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two time periods with the diff command, how to display only new errors from the last 24 hours that have NOT happened in the last 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158172#M44579</link>
      <description>&lt;P&gt;Another way to do this is run a scheduled report at midnight that outputs the error, msg, and program for the last 7 days to a lookup. Then you can run your 24 hour report on demand using the lookup to filter. This is probably best performance.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 10:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-time-periods-with-the-diff-command-how-to-display/m-p/158172#M44579</guid>
      <dc:creator>mfscully</dc:creator>
      <dc:date>2016-09-22T10:00:14Z</dc:date>
    </item>
  </channel>
</rss>

