<?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: Compare data in different souretypes with no common field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365718#M164205</link>
    <description>&lt;P&gt;Hi @kashifqau,&lt;BR /&gt;
Can you try below query if it helps you.&lt;BR /&gt;
index=xyz sourcetype=logs AND sourcetype=range| stats count BY num,range |search num&amp;gt;=lowerlimit AND num&amp;lt;=upperlimit&lt;/P&gt;</description>
    <pubDate>Tue, 26 Dec 2017 05:36:11 GMT</pubDate>
    <dc:creator>nikita_p</dc:creator>
    <dc:date>2017-12-26T05:36:11Z</dc:date>
    <item>
      <title>Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365715#M164202</link>
      <description>&lt;P&gt;I am having below situation&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I am having 2 different sourcetypes "logs" and "range". 

&lt;UL&gt;
&lt;LI&gt;logs contains log events which are having a field with name "num"&lt;/LI&gt;
&lt;LI&gt;range contains 2 different fields with names "lowerlimit" and "upperlimit"&lt;/LI&gt;
&lt;LI&gt;I have to create a search to get the "num" field from sourcetype "logs" and compare it in sourcetype(range) and display the lowerlimit and upperlimit for which num&amp;gt;=lowerlimit AND num&amp;lt;=upperlimit&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I created a main search to get "lowerlimit" and "upperlimit" and a subsearch to get "num", however after that I do not know how to perform the comparison.&lt;/P&gt;

&lt;P&gt;[I am having no common field among both these searches]&lt;/P&gt;

&lt;P&gt;Thank you and looking forward for a solution.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Dec 2017 23:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365715#M164202</guid>
      <dc:creator>kashifqau</dc:creator>
      <dc:date>2017-12-25T23:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365716#M164203</link>
      <description>&lt;P&gt;-- [I am having no common field among both these searches]&lt;/P&gt;

&lt;P&gt;For such a case, you can use -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; eval combined_field = coalesce(fielda, fieldb)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Dec 2017 23:30:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365716#M164203</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2017-12-25T23:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365717#M164204</link>
      <description>&lt;P&gt;Kashifqau, if you already have used a subsearch that gives you "num", the way to compare fields is the "where" command,&lt;BR /&gt;
so&lt;BR /&gt;
| where num&amp;gt;=lowerlimit AND num&amp;lt;=upperlimit&lt;/P&gt;

&lt;P&gt;Not sure why Splunk needs where separate from search, but where is what lets you compare fields in the same record.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 02:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365717#M164204</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-12-26T02:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365718#M164205</link>
      <description>&lt;P&gt;Hi @kashifqau,&lt;BR /&gt;
Can you try below query if it helps you.&lt;BR /&gt;
index=xyz sourcetype=logs AND sourcetype=range| stats count BY num,range |search num&amp;gt;=lowerlimit AND num&amp;lt;=upperlimit&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 05:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365718#M164205</guid>
      <dc:creator>nikita_p</dc:creator>
      <dc:date>2017-12-26T05:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365719#M164206</link>
      <description>&lt;P&gt;Thank you for replies&lt;/P&gt;

&lt;P&gt;@ddrillic , the coalesce function combines the 2 fields into a single one. In any case I have to make a condition between values of 2 different sourcetypes, which yields in no result. I am trying further with coalesce but as of now I didn't succeeded in it&lt;/P&gt;

&lt;P&gt;@MonkeyK, my issue is that i have to make a condition between fields in 2 different sourcetypes. In this case a normal where clause does not work because we are having data in below format&lt;/P&gt;

&lt;P&gt;num                lowerlimit                 upperlimit&lt;BR /&gt;
100&lt;BR /&gt;&lt;BR /&gt;
                         80                               110&lt;BR /&gt;
                         40                                60&lt;BR /&gt;
                         310                             400&lt;/P&gt;

&lt;P&gt;and so on. In this case &lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 07:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365719#M164206</guid>
      <dc:creator>kashifqau</dc:creator>
      <dc:date>2017-12-26T07:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365720#M164207</link>
      <description>&lt;P&gt;Thank you nikita_p for your reply.&lt;/P&gt;

&lt;P&gt;Sorry to say that provided search is not producing desire. stats count by num, range returns no result&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 07:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365720#M164207</guid>
      <dc:creator>kashifqau</dc:creator>
      <dc:date>2017-12-26T07:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365721#M164208</link>
      <description>&lt;P&gt;Can you please try using OR:-&lt;BR /&gt;
 sourcetype=logs OR sourcetype=range&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 07:49:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365721#M164208</guid>
      <dc:creator>nikita_p</dc:creator>
      <dc:date>2017-12-26T07:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Compare data in different souretypes with no common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365722#M164209</link>
      <description>&lt;P&gt;I see, so you have a subsearch that can get "num" from logs, but it does not include that value in the records from range.   &lt;/P&gt;

&lt;P&gt;There are a few ways to do this, including using this:&lt;BR /&gt;
use your current search and eventstats to get the value that you want&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| eventstats first(num) as num
| where num&amp;gt;=lowerlimit AND num&amp;lt;=upperlimit
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Dec 2017 21:12:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-data-in-different-souretypes-with-no-common-field/m-p/365722#M164209</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-12-26T21:12:43Z</dc:date>
    </item>
  </channel>
</rss>

