<?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 Comparing two fields from different sources in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155357#M43726</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I would like to compare two fields on a sequential way coming from different sourcetypes already indexed at splunk. For instance, the sourcetype 1 has the querys done by clients to the DNS. The sourcetype 2 contains a dynamic list of malicious domains. I would like to correlate both sourcetypes in order to know whether a client is trying to resolve a malicious domain. Example:&lt;BR /&gt;
sourcetype 1 (DNS)&lt;BR /&gt;
.&lt;A href="http://www.facebook.com"&gt;www.facebook.com&lt;/A&gt;&lt;BR /&gt;
.&lt;A href="http://www.google.com"&gt;www.google.com&lt;/A&gt;&lt;BR /&gt;
.&lt;A href="http://www.linkedin.com"&gt;www.linkedin.com&lt;/A&gt;&lt;BR /&gt;
.&lt;A href="http://www.malicious2.com"&gt;www.malicious2.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;sourcetype 2 (malicious domains)&lt;BR /&gt;
malicious1.com&lt;BR /&gt;
malicious2.com&lt;/P&gt;

&lt;P&gt;Expected result:&lt;/P&gt;

&lt;P&gt;malicious2.com &lt;/P&gt;

&lt;P&gt;Thanks a lot for the support!&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2013 16:08:09 GMT</pubDate>
    <dc:creator>cirrusfa</dc:creator>
    <dc:date>2013-11-25T16:08:09Z</dc:date>
    <item>
      <title>Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155357#M43726</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I would like to compare two fields on a sequential way coming from different sourcetypes already indexed at splunk. For instance, the sourcetype 1 has the querys done by clients to the DNS. The sourcetype 2 contains a dynamic list of malicious domains. I would like to correlate both sourcetypes in order to know whether a client is trying to resolve a malicious domain. Example:&lt;BR /&gt;
sourcetype 1 (DNS)&lt;BR /&gt;
.&lt;A href="http://www.facebook.com"&gt;www.facebook.com&lt;/A&gt;&lt;BR /&gt;
.&lt;A href="http://www.google.com"&gt;www.google.com&lt;/A&gt;&lt;BR /&gt;
.&lt;A href="http://www.linkedin.com"&gt;www.linkedin.com&lt;/A&gt;&lt;BR /&gt;
.&lt;A href="http://www.malicious2.com"&gt;www.malicious2.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;sourcetype 2 (malicious domains)&lt;BR /&gt;
malicious1.com&lt;BR /&gt;
malicious2.com&lt;/P&gt;

&lt;P&gt;Expected result:&lt;/P&gt;

&lt;P&gt;malicious2.com &lt;/P&gt;

&lt;P&gt;Thanks a lot for the support!&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2013 16:08:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155357#M43726</guid>
      <dc:creator>cirrusfa</dc:creator>
      <dc:date>2013-11-25T16:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155358#M43727</link>
      <description>&lt;P&gt;This should do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="DNS" | join field1 [search sourcetype="malicious domains" | rename field2 as field1]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where "field1" is the field from DNS sourcetype that has the domain, and field2 is the field from "malicioius domains" that has the domain.&lt;/P&gt;

&lt;P&gt;This will get you all the DNS events that have a matching domain from DNS in malicious domains.&lt;/P&gt;

&lt;P&gt;You can probably do something like this too:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(sourcetype="DNS" OR sourcetype="malicious domains") | rename field2 as field1 | dedup field1, sourcetype | stats count by field1 | where count &amp;gt; 1 | table field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you all the values of "field1" that have more than 1 sourcetype attached to them.&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2013 16:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155358#M43727</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-11-25T16:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155359#M43728</link>
      <description>&lt;P&gt;Extending first answer from @aholzer, you can do following (little faster):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="sourcetype1" | stats count by client,DNS | rename DNS as mals_domain | fields - count| join mals_domain [search sourcetype="sourcetype2" | stats count by mals_domain | fields - count]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above should give you client name along with mals domain accessed by him/her. Will return 0 records if a client is not hitting any malicious domains.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2013 16:57:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155359#M43728</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-25T16:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155360#M43729</link>
      <description>&lt;P&gt;Thanks @aholzer and @somesoni2 for your quick reply. Join indeed is the command that I have to use. However, I'm still having a problem with my query. When I'm doing the join, the matching between both searchs is not 100% accurated as there are some false positives included as a result of the query. For instance:&lt;/P&gt;

&lt;P&gt;Sourcer type 1 (dns)&lt;BR /&gt;
Domaingood1&lt;BR /&gt;
Domaingood2&lt;BR /&gt;
Domaingood3&lt;BR /&gt;
Maliciousdomain1&lt;BR /&gt;
Maliciousdomain2&lt;BR /&gt;
Domaingood3&lt;/P&gt;

&lt;P&gt;Sourcer type 2 (maldomains)&lt;BR /&gt;
Maliciousdomain1&lt;BR /&gt;
Maliciousdomain2&lt;BR /&gt;
Maliciousdomain3&lt;/P&gt;

&lt;P&gt;Result of the query&lt;BR /&gt;
Maliciousdomain1 --&amp;gt; OK&lt;BR /&gt;
Maliciousdomain2 --&amp;gt; OK&lt;BR /&gt;
Domaingood3 --&amp;gt; False positive&lt;/P&gt;

&lt;P&gt;In order to debug this error, I have split the left side (the search to obtain the domains resolved by the DNS) and right side (the malicious domains) of the join in a different search and saved the results in two different files (csv files). So, I have one csv with the domains resolved by the DNS and another csv with the malicious domains. After that, I did the join of both csv files in order to verify whether the result is the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup dns.csv| join value [inputlookup feesII.csv |fields value]  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output of this query is 100% correct and shows the results desired without falses positives. So, I don't understand why the first query is showing falses positives. &lt;/P&gt;

&lt;P&gt;Does anyody have an idea?&lt;/P&gt;

&lt;P&gt;Thank you in advance,&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 13:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155360#M43729</guid>
      <dc:creator>cirrusfa</dc:creator>
      <dc:date>2013-11-26T13:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155361#M43730</link>
      <description>&lt;P&gt;You should give us the search you are trying to run. &lt;/P&gt;

&lt;P&gt;Also you shouldn't post comments or updates to your question as answers, it just confuses things.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 15:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155361#M43730</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-11-26T15:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155362#M43731</link>
      <description>&lt;P&gt;sorry for not include my answer as a comment (first time using the forum). This is the query (big query) I'm running:&lt;/P&gt;

&lt;P&gt;sourcetype="DNS" NOT (dns_record_type="PTR") dns_client="Myip"| rex mode=sed "s/(\d+)/./g" | rex field=_raw "Regular Expresion to extract the domainname as domaindns" | stats count by dns_client,domaindns | fields - count | join domaindns[search sourcetype="Feeds" type="domain" | stats count by value| rename value as domaindns|fields - count]&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:22:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155362#M43731</guid>
      <dc:creator>cirrusfa</dc:creator>
      <dc:date>2020-09-28T15:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155363#M43732</link>
      <description>&lt;P&gt;I have not included the entire query (regular expersion) as i do not have enought space available.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 16:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155363#M43732</guid>
      <dc:creator>cirrusfa</dc:creator>
      <dc:date>2013-11-26T16:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155364#M43733</link>
      <description>&lt;P&gt;The reason you are getting the dupe is because of your "| stats count by dns_client,domaindns". Remove the "dns_client" from the by clause, and it should work.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155364#M43733</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2020-09-28T15:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155365#M43734</link>
      <description>&lt;P&gt;Thanks @aholzer, I have introduced the changes. When I'm doing the query only with My IP is working but when there is no a filter by IP the query is showing falses positives. If i perform the search from the last hour i have (8500 DNS records), (2 malicious domains) and the results are 7 domains (the 2 malicious so OK + 5 falses positives so good domains).&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 16:31:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155365#M43734</guid>
      <dc:creator>cirrusfa</dc:creator>
      <dc:date>2013-11-26T16:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields from different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155366#M43735</link>
      <description>&lt;P&gt;The query looks like:&lt;/P&gt;

&lt;P&gt;sourcetype="DNS" NOT (dns_record_type="PTR") | rex mode=sed "s/(\d+)/./g" | rex field=_raw "Rcv\s+[\d.]+\s+[\d,a-zA-Z]+\s+[A-Z]+\s[[\d,\s,A-z]+]\s+[A-Z]+\s+&lt;A href="https://community.splunk.com/?P%3Cdomaindns%3E%5Ba-zA-Z,.,-,d%5D+" target="_blank"&gt;.&lt;/A&gt;" | eval domaindns = substr(domaindns, 1, len(domaindns)-1)|stats count by domaindns | rename domaindns as value | fields - count | join value [search sourcetype="CTI" type="domain" | stats count by value| fields - count]&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:22:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-from-different-sources/m-p/155366#M43735</guid>
      <dc:creator>cirrusfa</dc:creator>
      <dc:date>2020-09-28T15:22:23Z</dc:date>
    </item>
  </channel>
</rss>

