<?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 compare the same search from the previous day to current day using set diff? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448687#M172402</link>
    <description>&lt;P&gt;You can thank @martin_mueller for that &lt;CODE&gt;setdiff&lt;/CODE&gt; line.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Mar 2019 16:25:16 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-03-18T16:25:16Z</dc:date>
    <item>
      <title>How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448684#M172399</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I am very new to Splunk (about 1 month or so) and I am having some trouble incorporating "set diff" into my search to compare the same search from previous day to now. Can anyone help??&lt;BR /&gt;
Below is my search used to retrieve the data i am looking for i am unsure where and how "set diff" should be used. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype= (blank) source="myfiles.csv"
| dedup displayName actions | table displayName actions
| rex field=actions "hosts\W+(?P.*?)]" max_match=0
| table displayName Hosts | mvexpand Hosts | makemv delim="," Hosts | rex mode=sed field=Hosts "s/'/ /g"
| mvexpand Hosts
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 15:11:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448684#M172399</guid>
      <dc:creator>darrenaefc</dc:creator>
      <dc:date>2019-03-18T15:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448685#M172400</link>
      <description>&lt;P&gt;Using set diff, it has to be done like this (two subsearches, one selecting data for yesterday and other selecting data for today)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search index=security sourcetype= (blank) source="myfiles.csv" earliest=-1d@d latest=@d
| dedup displayName actions | table displayName actions
| rex field=actions "hosts\W+(?P&amp;lt;Hosts&amp;gt;.*?)]" max_match=0
| table displayName Hosts | mvexpand Hosts | makemv delim="," Hosts | rex mode=sed field=Hosts "s/'/ /g"
| mvexpand Hosts]  [search index=security sourcetype= (blank) source="myfiles.csv" earliest=@d latest=now
| dedup displayName actions | table displayName actions
| rex field=actions "hosts\W+(?P&amp;lt;Hosts&amp;gt;.*?)]" max_match=0
| table displayName Hosts | mvexpand Hosts | makemv delim="," Hosts | rex mode=sed field=Hosts "s/'/ /g"
| mvexpand Hosts]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I would rather do it using below, better search (no subsearch, selecting data for yesterday and today)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype= (blank) source="myfiles.csv" earliest=-1d@d  latest=now
| bucket span=1d _time
| dedup _time displayName actions | table _time displayName actions
| rex field=actions "hosts\W+(?P&amp;lt;Hosts&amp;gt;.*?)]" max_match=0
| table _time displayName Hosts | mvexpand Hosts | makemv delim="," Hosts | rex mode=sed field=Hosts "s/'/ /g"
| mvexpand Hosts
| stats dc(_time) as daysReported by displayName Hosts | where daysReported=1 | table displayName Hosts 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 15:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448685#M172400</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-03-18T15:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448686#M172401</link>
      <description>&lt;P&gt;I would not use &lt;CODE&gt;set diff&lt;/CODE&gt; for many reasons; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype= (blank) source="myfiles.csv" earliest=-2d@d latest=@d
| dedup displayName actions
| fields displayName actions
| rex field=actions max_match=0 "hosts\W+(?P.*?)]"
| fields -actions
| mvexpand Hosts
| makemv delim="," Hosts | rex mode=sed field=Hosts "s/'/ /g"
| mvexpand Hosts
| bin _time span=1d
| eval _time = if(_time &amp;lt; relative_time(now(), "-1d@d"), "YesterYesterDay", "YesterDay")
| chart values(Hosts) OVER displayName BY _time
| nomv YesterYesterDay 
| nomv YesterDay 
| rex field=YesterYesterDay mode=sed "s/[\r\n\s]+/;/g" 
| rex field=YesterDay mode=sed "s/[\r\n\s]+/;/g" 
| eval setdiff = split(replace(replace(replace(replace(mvjoin(mvsort(mvappend(split(replace(YesterYesterDay, "(;|$)", "#1;"), ";"), split(replace(YesterDay, "(;|$)", "#0;"), ";"))), ";"), ";(\w+)#0\;\1#1", ""), ";\w+#1", ""), "#0", ""), ";(?!\w)|^;", ""), ";")
| makemv delim=";" YesterYesterDay
| makemv delim=";" YesterDay
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See this run-anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values(sourcetype) AS sourcetype WHERE index=_* earliest=-2d@d latest=@d BY host _time span=1d
| eval _time = if(_time &amp;lt; relative_time(now(), "-1d@d"), "YesterYesterDay", "YesterDay") 
| chart values(sourcetype) OVER host BY _time 
| nomv YesterYesterDay 
| nomv YesterDay 
| rex field=YesterYesterDay mode=sed "s/[\r\n\s]+/;/g" 
| rex field=YesterDay mode=sed "s/[\r\n\s]+/;/g" 
| eval setdiff = split(replace(replace(replace(replace(mvjoin(mvsort(mvappend(split(replace(YesterYesterDay, "(;|$)", "#1;"), ";"), split(replace(YesterDay, "(;|$)", "#0;"), ";"))), ";"), ";(\w+)#0\;\1#1", ""), ";\w+#1", ""), "#0", ""), ";(?!\w)|^;", ""), ";")
| makemv delim=";" YesterYesterDay
| makemv delim=";" YesterDay
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 15:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448686#M172401</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-18T15:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448687#M172402</link>
      <description>&lt;P&gt;You can thank @martin_mueller for that &lt;CODE&gt;setdiff&lt;/CODE&gt; line.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 16:25:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448687#M172402</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-18T16:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448688#M172403</link>
      <description>&lt;P&gt;@woodcock, whats this last &lt;CODE&gt;eval setdiff&lt;/CODE&gt; is doing here ?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 16:58:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448688#M172403</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2019-03-18T16:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448689#M172404</link>
      <description>&lt;P&gt;It manually calculates the difference between two multivalue fields.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 18:18:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448689#M172404</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2019-03-18T18:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448690#M172405</link>
      <description>&lt;P&gt;Which was the core of OPs ask.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 18:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448690#M172405</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-18T18:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448691#M172406</link>
      <description>&lt;P&gt;Attention @darrenaefc, I had a mistake in my original answer.  It works properly now.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 21:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448691#M172406</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-12T21:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the same search from the previous day to current day using set diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448692#M172407</link>
      <description>&lt;P&gt;It had a bug and wasn't working right.  Try it now.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 16:08:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-same-search-from-the-previous-day-to-current/m-p/448692#M172407</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-13T16:08:04Z</dc:date>
    </item>
  </channel>
</rss>

