<?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 table columns from 2 different searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271350#M81676</link>
    <description>&lt;P&gt;In a hurry I responded this as Answer earlier so I ask moderator to ignore it if possible.&lt;/P&gt;

&lt;P&gt;Back to the question. Somesoni2 your answer got me some results and I thank you on that but still it's not quite what I need.&lt;/P&gt;

&lt;P&gt;New search looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search index="A" source="/var/log/splunkusers" host="XYZ" user="*"] OR [search index="B" source="/var/log/secure" host="XYZ" user="*" | dedup user] | table user host _time source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and as a result I get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;userA       XYZ     2015-09-16 16:11:16 /var/log/secure
userB     XYZ   2015-09-23 15:24:38 /var/log/secure
userC        XYZ    2015-10-12 14:00:54 /var/log/secure
userA     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
userB     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
userC     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
userD       XYZ 2015-10-14 07:42:29 /var/log/splunkusers
userF     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and result what I need is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    userD        XYZ    2015-10-14 07:42:29 /var/log/splunkusers
    userF     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So basically I need only users from source /var/log/splunkusers that are not in /var/log/secure&lt;/P&gt;

&lt;P&gt;you suggested use of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats values(source) as source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it just groups me sources and there is no row with only one source so that I could use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| where mvcount(source) =1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;as you suggested. I get what you wanted to achieve and it would be ok. Can you please check my new search and example of results I get and results I need? It might give you better idea for possible solution.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2015 10:53:40 GMT</pubDate>
    <dc:creator>mkranjec</dc:creator>
    <dc:date>2015-10-14T10:53:40Z</dc:date>
    <item>
      <title>How to compare table columns from 2 different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271348#M81674</link>
      <description>&lt;P&gt;So I have two similar searches that use two different indexes. The output of both searches are tables and what I want is to compare 1st column from table 1 (result of Search 1) and 1st column from table 2 (result of Search 2).  &lt;/P&gt;

&lt;P&gt;Result should be diff of those two columns. &lt;STRONG&gt;Both columns contain a list of users and what I need are all users from column 1 (table1) that are not contained in column 2 (table2).&lt;/STRONG&gt; Both columns in both tables are named "user" and both contain same usernames but 1st table has all usernames and 2nd table have just few usernames.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Search 1:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="A" host="XYZ" source="ASDF" user="*" | table user host  _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Search 2:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="B" host="XYZ" source="FDSA" user="*" | table user host  _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I thought that It can be solved with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [Search1][Search2]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but for some reason it doesn't give me result that I need. &lt;/P&gt;

&lt;P&gt;I would appreciate any help with this problem.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2015 16:39:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271348#M81674</guid>
      <dc:creator>mkranjec</dc:creator>
      <dc:date>2015-10-13T16:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare table columns from 2 different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271349#M81675</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ( index="A" source="ASDF") OR (index="B" source="FDSA") host="XYZ" source="ASDF" user="*" | table user host _time source | eventstats values(source) as source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now to get the users which are not present in both the index/source, add this to above search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| where mvcount(source) =1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For users only in index A, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..| where mvcount(source)=1 AND source="ASDF"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Oct 2015 18:21:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271349#M81675</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-10-13T18:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare table columns from 2 different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271350#M81676</link>
      <description>&lt;P&gt;In a hurry I responded this as Answer earlier so I ask moderator to ignore it if possible.&lt;/P&gt;

&lt;P&gt;Back to the question. Somesoni2 your answer got me some results and I thank you on that but still it's not quite what I need.&lt;/P&gt;

&lt;P&gt;New search looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search index="A" source="/var/log/splunkusers" host="XYZ" user="*"] OR [search index="B" source="/var/log/secure" host="XYZ" user="*" | dedup user] | table user host _time source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and as a result I get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;userA       XYZ     2015-09-16 16:11:16 /var/log/secure
userB     XYZ   2015-09-23 15:24:38 /var/log/secure
userC        XYZ    2015-10-12 14:00:54 /var/log/secure
userA     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
userB     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
userC     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
userD       XYZ 2015-10-14 07:42:29 /var/log/splunkusers
userF     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and result what I need is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    userD        XYZ    2015-10-14 07:42:29 /var/log/splunkusers
    userF     XYZ   2015-10-14 07:42:29 /var/log/splunkusers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So basically I need only users from source /var/log/splunkusers that are not in /var/log/secure&lt;/P&gt;

&lt;P&gt;you suggested use of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats values(source) as source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it just groups me sources and there is no row with only one source so that I could use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| where mvcount(source) =1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;as you suggested. I get what you wanted to achieve and it would be ok. Can you please check my new search and example of results I get and results I need? It might give you better idea for possible solution.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 10:53:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-table-columns-from-2-different-searches/m-p/271350#M81676</guid>
      <dc:creator>mkranjec</dc:creator>
      <dc:date>2015-10-14T10:53:40Z</dc:date>
    </item>
  </channel>
</rss>

