<?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 do I compare the same search from two separate weeks? in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263624#M5133</link>
    <description>&lt;P&gt;Have you looked at the &lt;CODE&gt;appendcols&lt;/CODE&gt; command? You could try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=* earliest=-1w@w0 latest=@w0 | stats count as week1 by host ... | appencols [search sourcetype=* earliest=earliest=-2w@w latest=-1w@w | stats count as week2 by host ... ] | eval diff=week2-week1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 05 Dec 2015 20:41:28 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2015-12-05T20:41:28Z</dc:date>
    <item>
      <title>How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263623#M5132</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I have a search that I have scheduled to run twice as a report: once for last week (Sunday to Sunday) and once for the week prior (also Sunday to Sunday).  &lt;/P&gt;

&lt;P&gt;The search looks for Logins, and then lists the number of unique computers by the user who logged into them and the type of authentication that was used.  &lt;/P&gt;

&lt;P&gt;I need to compare these two reports - preferably with a third one, that way I can schedule them all after hours.  When they are compared, I need it to show:&lt;BR /&gt;
 1. usernames that show up on one report but not the other &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;BR /&gt;
 2. usernames that logged into a different number of hosts than in the other report -- like if a user logs into 20 hosts one week and 50 the next - I need the difference.  It can a percentage or just the number (like 50-20=30). &lt;/P&gt;

&lt;P&gt;Here is the search I'm currently running:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Login"
| eventstats dc(host) as distinct_hosts by UserName, Event, Authentication
| where distinct_hosts &amp;gt;= 2
| dedup host, UserName, Authentication
| stats dc(Computer) by UserName, Event, Authentication
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It doesn't much matter how it gets done within Spunk, it just needs to be schedule-able.  I've looked around a bunch, but haven't found anything that addresses this and this is beyond my Splunk knowledge level.  &lt;/P&gt;

&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2015 16:06:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263623#M5132</guid>
      <dc:creator>splunkfuinator</dc:creator>
      <dc:date>2015-12-05T16:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263624#M5133</link>
      <description>&lt;P&gt;Have you looked at the &lt;CODE&gt;appendcols&lt;/CODE&gt; command? You could try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=* earliest=-1w@w0 latest=@w0 | stats count as week1 by host ... | appencols [search sourcetype=* earliest=earliest=-2w@w latest=-1w@w | stats count as week2 by host ... ] | eval diff=week2-week1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Dec 2015 20:41:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263624#M5133</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-12-05T20:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263625#M5134</link>
      <description>&lt;P&gt;Thanks for the suggestion.  I tried adding this to my search, but had to add a "d" to "appencols".  It keeps telling me that whatever follows "appendcols" is an unknown search command ("Unknown search command 'sourcetype'").  &lt;/P&gt;

&lt;P&gt;Here's the updated search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Login" earliest=-1w@w0 latest=@w 
| stats count as week1 by host
| eventstats dc(host) as distinct_hosts by UserName, Event, Authentication
| where distinct_hosts &amp;gt;= 15 
| dedup host, TargetUserName, AuthenticationPackageName 
| stats dc(Computer) by UserName, Event, Authentication
| appendcols [sourcetype="Login" earliest=-1w@w0 latest=@w 
| stats count as week2 by host
| eventstats dc(host) as distinct_hosts by UserName, Event, Authentication
| where distinct_hosts &amp;gt;= 15 
| dedup host, UserName, Event, Authentication 
| stats dc(Computer) by UserName, Event, Authentication] 
| eval diff=week2-week1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Dec 2015 14:22:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263625#M5134</guid>
      <dc:creator>splunkfuinator</dc:creator>
      <dc:date>2015-12-09T14:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263626#M5135</link>
      <description>&lt;P&gt;You will have to put a keyword 'search' before the sourcetype inside the subsearch&lt;/P&gt;

&lt;PRE&gt;....| appendcols [search sourcetype="Login" earliest=-1w@w0 latest=@w &lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Dec 2015 14:55:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263626#M5135</guid>
      <dc:creator>pradeepkumarg</dc:creator>
      <dc:date>2015-12-09T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263627#M5136</link>
      <description>&lt;P&gt;That's right. Please add &lt;CODE&gt;search&lt;/CODE&gt;so your command will look like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| appendcols [search sourcetype="Login" earliest=-1w@w0 latest=@w 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Dec 2015 19:00:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263627#M5136</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-12-09T19:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263628#M5137</link>
      <description>&lt;P&gt;Got it, thanks!   Ok, so the only part I'm fuzzy on it how the time works -  I'd like the weeks to line up to the week prior (Sunday thru Sunday) and the week prior to that (also Sun thru Sun).   For example, if we were running it today (9 Dec 2015), one week would be 29 Nov - 6 Dec and one week would be 22 Nov - 29 Nov.  I've read the Splunk article on time modifiers and a few forum posts, and I just don't get the logic behind it.  The &lt;CODE&gt;earliest=-1w@w0 latest=@w&lt;/CODE&gt; above looks like it searches the same time period (previous week to now) in both the main search and the subsearch - can anyone explain this?&lt;BR /&gt;
URL for the time modifier page should be &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/SearchTimeModifiers"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/SearchTimeModifiers&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 20:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263628#M5137</guid>
      <dc:creator>splunkfuinator</dc:creator>
      <dc:date>2015-12-09T20:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare the same search from two separate weeks?</title>
      <link>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263629#M5138</link>
      <description>&lt;P&gt;You're right, the sub-search should be &lt;CODE&gt;earliest=-2w@w latest=-1w@w&lt;/CODE&gt;.  This will give you 11/22 to 11/29. The main search should be &lt;CODE&gt;earliest=-1w@w0 latest=@w0&lt;/CODE&gt; for 11/29 - 12/6. I've edited the original post&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 18:50:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-do-I-compare-the-same-search-from-two-separate-weeks/m-p/263629#M5138</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-12-11T18:50:33Z</dc:date>
    </item>
  </channel>
</rss>

