<?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: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622480#M216389</link>
    <description>&lt;LI-CODE lang="markup"&gt;sourcetype="source1" OR sourcetype="source2"
| eval key=coalesce(key,CID)
| stats values(*) as * by key&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 29 Nov 2022 18:17:35 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-11-29T18:17:35Z</dc:date>
    <item>
      <title>Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622461#M216378</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have 2 sourcetype sourcetype="source1" and sourcetype="source2"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is how sample data looks:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;source1:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CID,Cname,CData&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Source 2:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CID,key,FName,LName&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here values of &lt;STRONG&gt;CID&lt;/STRONG&gt; of &lt;STRONG&gt;source 1&lt;/STRONG&gt; and &lt;STRONG&gt;key&lt;/STRONG&gt; of &lt;STRONG&gt;source 2&lt;/STRONG&gt; will be same.Even though CID will be present in source 2 but it will be having different value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need to write query to when&amp;nbsp;CID(source 1) = key (source 2) then fetch all other fields from source 1 and source 2 display in table .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any suggestions would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 17:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622461#M216378</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-29T17:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622479#M216388</link>
      <description>&lt;P&gt;Something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source IN (source1, source2)
| stats values(Cname) as Cname, values(CData) as CData, values(key) as key, values(FName) as FName, values(LName) as LName values(source) by CID
| where mvcount('values(source)') &amp;gt; 1&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 18:15:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622479#M216388</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-29T18:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622480#M216389</link>
      <description>&lt;LI-CODE lang="markup"&gt;sourcetype="source1" OR sourcetype="source2"
| eval key=coalesce(key,CID)
| stats values(*) as * by key&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 29 Nov 2022 18:17:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622480#M216389</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-29T18:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622542#M216421</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;I have tried the above query.But it doesn't seems to be working as&amp;nbsp;coalesce is not matching if the values of CID(source1) and Key(source 2 ) same .Also its displaying only the fields of source 1.Fields of source 2 are not being fetched.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 03:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622542#M216421</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-30T03:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622543#M216422</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;I have tried this and not working.&lt;/P&gt;&lt;P&gt;As i need to match CID of source 1 and Key of source 2 are same then fetch all the fields of source1 and source 2.One thing to note here though CID is present in source 2 it will be having different value.so need to match if(CID(source1) equals to key(source2) then fetch all fields of source1 and source2). please suggest.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 03:11:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622543#M216422</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-30T03:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622571#M216430</link>
      <description>&lt;P&gt;What do you think coalesce is doing?&lt;/P&gt;&lt;P&gt;coalesce is simply creating a field called key using the value in field key (if it exists as in source 2) or CID (if it doesn't exist as in source 1). This is similar to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval key=if(isnotnull(key), key, CID)&lt;/LI-CODE&gt;&lt;P&gt;Having got a value in key, the stats is matching the events from both source 1 and source 2 by the value in key (where key = CID for source 1). Is this not what you wanted?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 08:36:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622571#M216430</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-30T08:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622581#M216437</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;Yes, that is what I am looking for .&lt;/P&gt;&lt;P&gt;But the catch here is &lt;STRONG&gt;CID is present in both &lt;STRONG&gt;source1 and &lt;STRONG&gt;source 2.&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;source1:&lt;/P&gt;&lt;P&gt;CID, Cname, CData&lt;/P&gt;&lt;P&gt;Source 2:&lt;/P&gt;&lt;P&gt;CID, key, FName, LName&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But i need to match CID of source 1 and key of source 2.Since CID field name is &lt;STRONG&gt;common in &lt;STRONG&gt;both the sources its not fetching properly as combined results .Its giving 2 rows of data for each sources having fields as null for other source.&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope I am making it clear.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please suggest .&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 09:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622581#M216437</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-30T09:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622583#M216438</link>
      <description>&lt;LI-CODE lang="markup"&gt;sourcetype="source1" OR sourcetype="source2"
| eval common=if(sourcetype="source2",key,CID)
| stats values(*) as * by common&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Nov 2022 09:49:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622583#M216438</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-30T09:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622587#M216440</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;it is fetching only the fields of source 1 and not combining the fields of both source 1 and source 2:(&lt;/P&gt;&lt;P&gt;In below CID will be taken from source 1? my use case is to match key of source 2 and CID of source 1But CID present in both the sources.&lt;/P&gt;&lt;P&gt;| eval common=if(sourcetype="source2",key,CID)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 10:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622587#M216440</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-30T10:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622590#M216441</link>
      <description>&lt;P&gt;The statement is putting the value from the key field in the common field if the sourcetype is "source2" and the value of the CID field in the common field if the sourcetype is not "source2". How is this not what you want?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 10:28:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622590#M216441</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-30T10:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622599#M216448</link>
      <description>&lt;P&gt;Thank you for your patience and response.&lt;/P&gt;&lt;P&gt;Just briefing here with sample data.Please suggest.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sourcetype=&lt;/EM&gt; source1&lt;EM&gt;&lt;BR /&gt;"CID": 123&lt;BR /&gt;"Cname": John&lt;BR /&gt;"CData": XYZ&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sourcetype=&lt;/EM&gt; source2&lt;EM&gt;&lt;BR /&gt;"CID": 285&lt;BR /&gt;"Key": 123,&lt;BR /&gt;"FName": Ken&lt;BR /&gt;"LName": Dan&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Here CID(source1) = Key(source 2) so I need result in below format:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"Cname": John&lt;/EM&gt;&lt;EM&gt;&lt;BR /&gt;"CData": XYZ&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"CID": 285&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"FName": Ken&lt;/EM&gt;&lt;EM&gt;&lt;BR /&gt;"LName": Dan&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;But with the below query I am seeing the result like below:&lt;/P&gt;&lt;P&gt;sourcetype="source1" OR sourcetype="source2"&lt;/P&gt;&lt;P&gt;| eval common=if(sourcetype="source2",key,CID)&lt;/P&gt;&lt;P&gt;| stats values(*) as * by common&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;"common": 123&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;"CID": 123&lt;/EM&gt;&lt;EM&gt;&lt;BR /&gt;"Cname": John&lt;BR /&gt;"CData": XYZ&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;There are no fields of source 2(FName,LName) is fetched here&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 11:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622599#M216448</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-30T11:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622607#M216452</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time

| eval sourcetype= "source1", "CID"= 123,"Cname"="John","CData"= "XYZ"
| append
    [makeresults
    | fields - _time
    | eval sourcetype= "source2","CID"= 285,"Key"= 123,"FName"= "Ken","LName"= "Dan"]
``` the lines above just set up your sample data ```    

| eval common=if(sourcetype="source2",Key,CID)
| eval CID=if(sourcetype="source2",CID,null())

| stats values(*) as * by common
| fields - common sourcetype Key&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Nov 2022 11:53:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622607#M216452</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-30T11:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622614#M216458</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;Apologies for the multiple threads.&lt;/P&gt;&lt;P&gt;I did try below both the queries you have suggested and its fetching only the fields of &lt;STRONG&gt;source1&lt;/STRONG&gt; .(i.e CID, Cname ,CData). Source2 fields are not being combined and fetched.&lt;/P&gt;&lt;P&gt;I am not sure what am missing here .Please suggest.&lt;/P&gt;&lt;P class=""&gt;sourcetype="source1" OR sourcetype="source2"&lt;/P&gt;&lt;P class=""&gt;| eval common=if(sourcetype="source2",key,CID)&lt;/P&gt;&lt;P class=""&gt;| stats values(*) as * by common&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;sourcetype="source1" OR sourcetype="source2"&lt;/P&gt;&lt;P class=""&gt;| eval common=if(sourcetype="source2",Key,CID)&lt;/P&gt;&lt;P class=""&gt;| eval CID=if(sourcetype="source2",CID,null())&lt;/P&gt;&lt;P class=""&gt;| stats values(*) as * by common&lt;/P&gt;&lt;P class=""&gt;| fields - common sourcetype Key&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 12:20:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622614#M216458</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-11-30T12:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622617#M216459</link>
      <description>&lt;P&gt;You should only need the lower part&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="source1" OR sourcetype="source2"
``` Set common to Key if sourcetype is source2 otherwise use CID (or source1 events) ```
| eval common=if(sourcetype="source2",Key,CID)
``` Preserve CID for sourcetype source2 otherwise clear the field (as you don't appear to be interested in this value) ```
| eval CID=if(sourcetype="source2",CID,null())
``` Gather all the fields from both sourcetypes where Key from source2 = CID from source1 ```
| stats values(*) as * by common
| fields - common sourcetype Key&lt;/LI-CODE&gt;&lt;P&gt;If you are still not getting a match, this seems to suggest that CID in source1 has no matches for Key in source2&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 12:52:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622617#M216459</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-30T12:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search for between 2 sourcetypes where field 1 of source1 matches with field 2 of source 2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622760#M216502</link>
      <description>&lt;P&gt;I will try this .Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 06:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-for-between-2-sourcetypes-where-field-1-of-source1/m-p/622760#M216502</guid>
      <dc:creator>M28</dc:creator>
      <dc:date>2022-12-01T06:59:00Z</dc:date>
    </item>
  </channel>
</rss>

