<?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: Adding 'host' field to a set diff command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321463#M96039</link>
    <description>&lt;P&gt;Do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=example sourcetype=example host=host1 OR host=host2
| stats values(host) AS hosts BY FIELD
| where mvcount(hosts)=1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Jul 2017 16:12:39 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-07-20T16:12:39Z</dc:date>
    <item>
      <title>Adding 'host' field to a set diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321462#M96038</link>
      <description>&lt;P&gt;My set diff query compares the values of one field from two different hosts and outputs a list of the field values that are unique to one host or the other. However, I can't seem to find a way to also display the host name alongside the output. I am trying to get a list of values that are unique to one host and know which host they have come from.&lt;/P&gt;

&lt;P&gt;The query follows this format: &lt;/P&gt;

&lt;P&gt;| set diff [index=example sourcetype=example host=host1 | table FIELD] [index=example sourcetype=example host=host2 | table FIELD] &lt;/P&gt;

&lt;P&gt;It will then output a list of values for that field that are unique to one host or the other, but I have no way of knowing which host they are unique to. If I include host in the table part of the subsearches it will return all entries, since the host is different in all cases. &lt;/P&gt;

&lt;P&gt;I'm looking for something like this &lt;/P&gt;

&lt;P&gt;Field  host&lt;BR /&gt;
1234  host1&lt;BR /&gt;
5678  host2&lt;BR /&gt;
9101  host1&lt;BR /&gt;
2345  host1&lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:04:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321462#M96038</guid>
      <dc:creator>leonienicks</dc:creator>
      <dc:date>2017-07-20T16:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Adding 'host' field to a set diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321463#M96039</link>
      <description>&lt;P&gt;Do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=example sourcetype=example host=host1 OR host=host2
| stats values(host) AS hosts BY FIELD
| where mvcount(hosts)=1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:12:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321463#M96039</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-20T16:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding 'host' field to a set diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321464#M96040</link>
      <description>&lt;P&gt;Thanks so much - this is great! The only thing is that it won't display any duplicate extra results to one host so for example, if host1 has event A once and host2 has event A twice, since it's the same value it won't show in this. Perhaps there is a separate query that would fetch this?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:40:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321464#M96040</guid>
      <dc:creator>leonienicks</dc:creator>
      <dc:date>2017-07-20T16:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding 'host' field to a set diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321465#M96041</link>
      <description>&lt;P&gt;OK, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=example sourcetype=example host=host1 OR host=host2
| stats count BY host FIELD
| eventstats dc(host) AS hosts BY FIELD
| where Your Logic Here
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 21:33:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321465#M96041</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-20T21:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adding 'host' field to a set diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321466#M96042</link>
      <description>&lt;P&gt;Thanks! This inspired me to do something else I was working on, which was that for the same unique ID field, fetching the results that had differences elsewhere in the events: &lt;BR /&gt;
index=example sourcetype=example host=host1 OR host=host2&lt;BR /&gt;
 | eventstats dc(host) AS uniqueID BY FIELD&lt;BR /&gt;
 | where uniqueID = 2&lt;BR /&gt;
 | eval raw=toString(FIELD)+"|"+toString(FIELD2)+"|"+toString(FIELD3)&lt;BR /&gt;
 | stats values(host) AS hosts BY raw&lt;BR /&gt;
 | where mvcount(hosts) = 1&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 14:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-host-field-to-a-set-diff-command/m-p/321466#M96042</guid>
      <dc:creator>leonienicks</dc:creator>
      <dc:date>2017-07-26T14:57:27Z</dc:date>
    </item>
  </channel>
</rss>

