<?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: Match and compare fields with different names and from different sources in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472421#M192319</link>
    <description>&lt;P&gt;So I can see the search results when using the first half of the search you suggested...&lt;/P&gt;

&lt;P&gt;"| union  [ search index="1" sourcetype="1" source="1" | search state="running" | rename vm_name AS hostname ]&lt;BR /&gt;
 [ search index="2" source="2" group=tcpin_connections | dedup hostname ]"&lt;/P&gt;

&lt;P&gt;Additionally, if I remove "rename vm_name AS hostname" from the search, I am able to see both indexes, sourcetypes, source, vm_name, and hostname.&lt;BR /&gt;
So I then tried to table to hostname field by itself and I get a list of the hostname but also a ton of blank results. Same for viewing the vm_name field by itself. &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 04:57:26 GMT</pubDate>
    <dc:creator>garciajbg</dc:creator>
    <dc:date>2020-09-30T04:57:26Z</dc:date>
    <item>
      <title>Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472412#M192310</link>
      <description>&lt;P&gt;Ok, so I a trying my best to evaluate the differences between two search results. &lt;/P&gt;

&lt;P&gt;Search 1 gives me a list of  "vm_name"&lt;BR /&gt;
index="1" sourcetype="1" source="1" | search state="running" | table vm_name&lt;/P&gt;

&lt;P&gt;Search 2 gives me a list of "hostname"&lt;BR /&gt;
index="2" source="2*" group=tcpin_connections | dedup hostname | table hostname&lt;/P&gt;

&lt;P&gt;Each search is crafted from two different indexes and sourcetypes. &lt;/P&gt;

&lt;P&gt;Both of these lists share common field values. For example, in search 1 &lt;STRONG&gt;vm_name&lt;/STRONG&gt; can be named "MYPC" and on search 2 &lt;STRONG&gt;hostname&lt;/STRONG&gt; is also "MYPC". Both are named MYPC and in reality, they are one and the same. However, I need to create a list that will essentially compare the values of both searches and if they match subtract them from one another and create the NEW list. The goal to remove MATCHED results from both searches to create a "DELTA's" list.&lt;/P&gt;

&lt;P&gt;I have tried the "join" command but when I do the results from the second search results are completely messed up. I tried created lookups and added them to one search but I have the same problem. The only thing I can think of is maybe the issue is the search itself may yield metadata somewhere that screws up the results.  For example, on search 2 I need to add "dedup hostname" to the search to retrieve an accurate list.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472412#M192310</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-09-30T04:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472413#M192311</link>
      <description>&lt;P&gt;One way to do this is to set up a multisearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch
[ search index="1" sourcetype="1" source="1" | search state="running" | table vm_name | rename vm_name AS hostname ]
[ search index="2" source="2*" group=tcpin_connections | dedup hostname | table hostname]
| stats count(index) AS Vol first(index) AS index by hostname
| where Vol=1
| eval message=if(index==1,"Host belongs to index 1 only","Host belongs to index 2 only")
| fields hostname message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test this with some "run anywhere" SPL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval raw="index=1,sourcetype=1,source=1,hostname=1a index=1,sourcetype=1,source=1,hostname=1b index=1,sourcetype=1,source=1,hostname=1c index=1,sourcetype=1,source=1,hostname=1d index=1,sourcetype=1,source=1,hostname=1e index=2,sourcetype=,source=2,hostname=2a index=2,sourcetype=,source=2,hostname=2b index=2,sourcetype=,source=2,hostname=1a index=2,sourcetype=,source=2,hostname=2g "
| makemv raw | mvexpand raw | rename raw AS _raw | kv
| table index sourcetype,source,hostname
| stats count(index) AS Vol first(index) AS index by hostname
| where Vol=1
| eval message=if(index==1,"hostname belongs to index 1 only","hostname belongs to index 2 only")
| fields hostname message
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2020 16:59:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472413#M192311</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-04-14T16:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472414#M192312</link>
      <description>&lt;P&gt;@jpolvino I tried the multisearch command but received the following error.&lt;/P&gt;

&lt;P&gt;"Error in 'multisearch' command: Multisearch subsearches may only contain purely streaming operations (subsearch 1 contains a non-streaming command.)" &lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 17:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472414#M192312</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-04-14T17:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472415#M192313</link>
      <description>&lt;P&gt;Get rid of &lt;CODE&gt;table vm_name&lt;/CODE&gt; in the first subsearch, and &lt;CODE&gt;table hostname&lt;/CODE&gt; in the second subsearch.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:12:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472415#M192313</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-04-14T18:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472416#M192314</link>
      <description>&lt;P&gt;Got the following error.&lt;/P&gt;

&lt;P&gt;"Error in 'multisearch' command: Multisearch subsearches may only contain purely streaming operations (subsearch 2 contains a non-streaming command.)"&lt;/P&gt;

&lt;P&gt;However, the "dedup hostname" is needed in order to accurately list hosts. If I remove it from the search I get the list of all "vm_name" values in the Hostname field and "Host belongs to index 2 only" on ALL the message field values.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:23:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472416#M192314</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-04-14T18:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472417#M192315</link>
      <description>&lt;P&gt;I also tried running it with "stats count by hostname" and get the same results&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:40:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472417#M192315</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-04-14T18:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472418#M192316</link>
      <description>&lt;P&gt;So your first 3 lines should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch
[ search index="1" sourcetype="1" source="1" | search state="running" | rename vm_name AS hostname ]
[ search index="2" source="2*" group=tcpin_connections | dedup hostname ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this what you have? If so, then all events will have "hostname" which is needed later on.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:43:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472418#M192316</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-04-14T18:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472419#M192317</link>
      <description>&lt;P&gt;Yes, that is what I have. The error I get when I try to run it is "subsearch 2 contains a non-streaming command". It does not like the "dedup hostname" on search 2.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472419#M192317</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-04-14T18:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472420#M192318</link>
      <description>&lt;P&gt;Ok, leave the &lt;CODE&gt;dedup&lt;/CODE&gt; in there, and change the top line from &lt;CODE&gt;multisearch&lt;/CODE&gt; to &lt;CODE&gt;union&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 20:54:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472420#M192318</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-04-14T20:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472421#M192319</link>
      <description>&lt;P&gt;So I can see the search results when using the first half of the search you suggested...&lt;/P&gt;

&lt;P&gt;"| union  [ search index="1" sourcetype="1" source="1" | search state="running" | rename vm_name AS hostname ]&lt;BR /&gt;
 [ search index="2" source="2" group=tcpin_connections | dedup hostname ]"&lt;/P&gt;

&lt;P&gt;Additionally, if I remove "rename vm_name AS hostname" from the search, I am able to see both indexes, sourcetypes, source, vm_name, and hostname.&lt;BR /&gt;
So I then tried to table to hostname field by itself and I get a list of the hostname but also a ton of blank results. Same for viewing the vm_name field by itself. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472421#M192319</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-09-30T04:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Match and compare fields with different names and from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472422#M192320</link>
      <description>&lt;P&gt;Ok, I was able to finally able to get everything tabled correctly by adding "appendcols" between both searches. See below.&lt;/P&gt;

&lt;P&gt;| union [search index=1 sourcetype=1 source=1 | search state="running" | table vm_name private_ip_address ]  &lt;STRONG&gt;| appendcols&lt;/STRONG&gt; [ search index=2 source="&lt;EM&gt;2&lt;/EM&gt;" group=tcpin_connections | dedup hostname | table hostname sourceIp ] &lt;/P&gt;

&lt;P&gt;I then tried to add the below to try a filter out matching IP's between "sourceIp and private_ip_address". This kinda works but also creates weird formatting with final results. Since all IP's listed in "sourceIp"  will also be listed in "private_ip_addresses" but NOT vice versa I need to list the delta between the two. The below gives me IPs that match between both but I can not compare the difference due to some formating. Is there a better way to list the "private_ip_address" IPs that are not found in "sourceIp'? &lt;/P&gt;

&lt;P&gt;| eval fan=mvappend("A","B") | mvexpand fan | eval matchIP=if(fan="A",private_ip_address,sourceIp) | stats dc(fan) as matchcount, values(*) as * by matchIP | where matchcount &amp;gt; 1&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-and-compare-fields-with-different-names-and-from-different/m-p/472422#M192320</guid>
      <dc:creator>garciajbg</dc:creator>
      <dc:date>2020-09-30T05:12:06Z</dc:date>
    </item>
  </channel>
</rss>

