<?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: Merge search from 2 different source in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596382#M207615</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245505"&gt;@aymane96&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;let me understand: has the main search results?&lt;/P&gt;&lt;P&gt;could you share some sample of x and y and value, to better understand conditions?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 13:23:17 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-05-04T13:23:17Z</dc:date>
    <item>
      <title>How to merge search from 2 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596376#M207610</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to do a search to filter some result matching my conditions and then use a common ID field to combine result with an other source.&lt;/P&gt;
&lt;P&gt;Lets say :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SOURCE A :&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;field ID&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;field x&lt;/LI&gt;
&lt;LI&gt;field y&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SOURCE B :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;field ID&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;field z&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do a search with some condition on Source A : Index=A sourcetype=A'&amp;nbsp; "x=value" "y&amp;lt;=value"&lt;/P&gt;
&lt;P&gt;and then use a join to get value "z"&amp;nbsp; for the result that i got from main search.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now i have something like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=A sourcetype=A'  "x=value" "y&amp;lt;=value"
| join [ search index=B sourcetype=B' | fields ID
| stats count by z&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does not seems to work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 16:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596376#M207610</guid>
      <dc:creator>aymane96</dc:creator>
      <dc:date>2022-05-04T16:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merge search from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596377#M207611</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245505"&gt;@aymane96&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;remember that Splunk isn't a DB, so join command must be used only when there isn't any other solution as last choice, because it's very slow and consumes many resources!&lt;/P&gt;&lt;P&gt;in you case, you could join the two sources using the stats command BY the common key (z), something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=A sourcetype=A "x=value" "y&amp;lt;=value") OR (index=B sourcetype=B)
| stats values(x) AS x values(y) AS y count by z&lt;/LI-CODE&gt;&lt;P&gt;if in addition you want also to put the condition that common key (z) values must be in both indexes, you could use something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=A sourcetype=A "x=value" "y&amp;lt;=value") OR (index=B sourcetype=B)
| stats values(x) AS x values(y) AS y dc(index) AS dc_index count by z
| where dc_index=2&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 13:04:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596377#M207611</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-05-04T13:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merge search from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596378#M207612</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=A sourcetype=A  x="value"
| where y&amp;lt;=value
| join ID [ search index=B sourcetype=B | fields ID z ]
| stats count by z&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 May 2022 13:04:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596378#M207612</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-05-04T13:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merge search from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596380#M207613</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your quick answer&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tried to use the stats command. I just tried your method but the problem is that i have more result with this query than the main search:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;index=A sourcetype=A "x=value" "y&amp;lt;=value"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;It seems that it does not match only these result but it is more like it appends all the result of the search&lt;/P&gt;&lt;PRE&gt;index=B sourcetype=B&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, i want to use index B just for the information in field z,&amp;nbsp; the scope will be the result of the main search.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 13:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596380#M207613</guid>
      <dc:creator>aymane96</dc:creator>
      <dc:date>2022-05-04T13:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merge search from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596382#M207615</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245505"&gt;@aymane96&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;let me understand: has the main search results?&lt;/P&gt;&lt;P&gt;could you share some sample of x and y and value, to better understand conditions?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 13:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-search-from-2-different-sources/m-p/596382#M207615</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-05-04T13:23:17Z</dc:date>
    </item>
  </channel>
</rss>

