<?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 can I diff the results of two most recent sources? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168236#M47960</link>
    <description>&lt;P&gt;Unless your log files are just numbers (not very likely), you'll have to go through some steps to find the previous log.  First you'll need to parse maxsource to separate the numeric part from the rest.  Then decrement the number and put the two parts back together.  Finally, run your &lt;CODE&gt;set diff&lt;/CODE&gt; using the two sources.  Here is an untested example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eventstats max(source) as maxsource | rex field=maxsource "(?P&amp;lt;base&amp;gt;[^\d]+)(?P&amp;lt;numeric&amp;gt;\d+)" | eval numeric=numeric-1 | eval prevsource=base.numeric | set diff [ search source=maxsource] [search source=prevsource] ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course, you'll want to modify the &lt;CODE&gt;rex&lt;/CODE&gt; command to match your filename format.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Aug 2015 18:06:20 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2015-08-11T18:06:20Z</dc:date>
    <item>
      <title>How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168235#M47959</link>
      <description>&lt;P&gt;I'm currently trying to generate a report describing "what's changed" since the last report.&lt;BR /&gt;&lt;BR /&gt;
Currently, my idea is to find the two most recent source files and run a "set diff" on their events.&lt;BR /&gt;
Unfortunately, while I can find the events from the most recent source file:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats max(source) as maxsource | where source = maxsource //Our log files are named with increasing numbers.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't figure out a way to find the events from the second most recent source file.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 16:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168235#M47959</guid>
      <dc:creator>chustar</dc:creator>
      <dc:date>2015-08-11T16:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168236#M47960</link>
      <description>&lt;P&gt;Unless your log files are just numbers (not very likely), you'll have to go through some steps to find the previous log.  First you'll need to parse maxsource to separate the numeric part from the rest.  Then decrement the number and put the two parts back together.  Finally, run your &lt;CODE&gt;set diff&lt;/CODE&gt; using the two sources.  Here is an untested example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eventstats max(source) as maxsource | rex field=maxsource "(?P&amp;lt;base&amp;gt;[^\d]+)(?P&amp;lt;numeric&amp;gt;\d+)" | eval numeric=numeric-1 | eval prevsource=base.numeric | set diff [ search source=maxsource] [search source=prevsource] ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course, you'll want to modify the &lt;CODE&gt;rex&lt;/CODE&gt; command to match your filename format.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 18:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168236#M47960</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-08-11T18:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168237#M47961</link>
      <description>&lt;P&gt;set diff will only work as a generating command (it has to be the first command)&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 18:14:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168237#M47961</guid>
      <dc:creator>steveyz</dc:creator>
      <dc:date>2015-08-11T18:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168238#M47962</link>
      <description>&lt;P&gt;I'd suggest running a subsearch using either tstats or metadata to get the last 2 sources, and then doing a search like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;subsearch to get last 2 source names&amp;gt;] | stats dc(source) as dc by _raw | search dc=1 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will get you all the rows that appear in only 1 of the last 2 sources.  Replace '_raw' with whatever other field(s) to fit your needs.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 18:18:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168238#M47962</guid>
      <dc:creator>steveyz</dc:creator>
      <dc:date>2015-08-11T18:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168239#M47963</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [  search 'your base search' [search 'your base search' | dedup source | head 1 | table source] | rest of the search  ]   [search 'your base search' | dedup source | head 2 | reverse | head 1 | table source ]| rest of the search ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Aug 2015 18:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168239#M47963</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-08-11T18:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168240#M47964</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | dedup source | sort 2 - source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then to get the events from those 2 sources, you do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... [search ... | dedup source | sort 2 - source | fields source]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Aug 2015 19:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168240#M47964</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-11T19:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I diff the results of two most recent sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168241#M47965</link>
      <description>&lt;P&gt;Thanks but the logs arent' incrementing. They numbers increase by arbitrary amounts based on outside factors that can't easily be predicted.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 22:19:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-diff-the-results-of-two-most-recent-sources/m-p/168241#M47965</guid>
      <dc:creator>chustar</dc:creator>
      <dc:date>2015-08-11T22:19:26Z</dc:date>
    </item>
  </channel>
</rss>

