<?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: How to match events from 3 different sources? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434129#M170670</link>
    <description>&lt;P&gt;In that case you need to include a &lt;CODE&gt;fillnull&lt;/CODE&gt; statement as follows :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  (index=cim source=A) OR (index=cim source=B) OR (index=cim source=C) 
 | rename CALLERNO AS Cell CALLEDNO AS Cell
 | stats latest(_time) as _time, values(Agent) as Agent, values(STAFF) as STAFF by Cell
| fillnull value="Not-found"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Jun 2019 11:26:28 GMT</pubDate>
    <dc:creator>DavidHourani</dc:creator>
    <dc:date>2019-06-19T11:26:28Z</dc:date>
    <item>
      <title>How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434124#M170665</link>
      <description>&lt;P&gt;I have one index with events from 3 different sources. I want to match one field of 1st source with other 2 source's events. &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Source "A" have two field/column name "Cell" &amp;amp; "Agent". The value of "Cell" is the phone no and it is also for source B &amp;amp; C.&lt;/LI&gt;
&lt;LI&gt;Source "B" have two field/column name "CALLERNO" &amp;amp; "STAFF".&lt;/LI&gt;
&lt;LI&gt;Source "C" have three field/column name "Cell", "CALLEDNO"  &amp;amp; "STAFFNO"&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Now I want to match the value of "Cell" from source "A" with source "B" (with field  "CALLERNO" ) &amp;amp; "C" (with field "CALLEDNO"). &lt;BR /&gt;
Please help me with command, how to get my expected result.  I tried with below code but I can get result from two source and can't get from 3 source. How can I match the events among these 3 sources.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cim  source=A  |  rename "Cell" as "CALLERNO" | join CALLERNO type=left usetime=true earlier=true    [search index=cim  source=B   earliest=-10m latest=now     | fields _time,CALLERNO,STAFF] | fillnull value="Not found"  | table _time,CALLERNO,Agent,STAFF
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 05:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434124#M170665</guid>
      <dc:creator>spnewashik</dc:creator>
      <dc:date>2019-06-19T05:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434125#M170666</link>
      <description>&lt;P&gt;Hi @spnewashik,&lt;/P&gt;

&lt;P&gt;You can do that without using any &lt;CODE&gt;join&lt;/CODE&gt; whatsoever by using a &lt;CODE&gt;stats&lt;/CODE&gt; command as follows :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=cim source=A) OR (index=cim source=B) OR (index=cim source=C) 
| rename CALLERNO AS Cell CALLEDNO AS Cell
| stats latest(_time) as _time, values(Agent) as Agent, values(STAFF) as STAFF by Cell
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 09:13:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434125#M170666</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T09:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434126#M170667</link>
      <description>&lt;P&gt;How about something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cim
| eval Cell = coalesce(Cell,CALLERNO,CALLEDNO)
| stats values(agent) as agent values(STAFF) as caller_staff values(STAFFNO) as called_staff by Cell
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 09:42:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434126#M170667</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-19T09:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434127#M170668</link>
      <description>&lt;P&gt;thanks for your reply. actually it doesn't bring my expected result. &lt;BR /&gt;
below is my actual expected output if the value of Cell (source A) is matched with value of CALLERNO (source B) and value of CALLEDNO (source C). If not match then it will shows "Not-Found" in event field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;time                  Cell         Agent      STAFF       STAFFNO
2019-06-11 09:50:00 12445678        Bob   Not-found     Jon 
2019-06-11 09:46:00 12997865        Alex      Don          Not-found
2019-06-11 09:45:00 12776547        Alice    Alice        Not-found
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 11:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434127#M170668</guid>
      <dc:creator>spnewashik</dc:creator>
      <dc:date>2019-06-19T11:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434128#M170669</link>
      <description>&lt;P&gt;actually it doesn't bring my expected result. &lt;BR /&gt;
below is my actual expected output if the value of Cell (source A) is matched with value of CALLERNO (source B) and value of CALLEDNO (source C). If not match then it will shows "Not-Found" in event field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;time                  Cell         Agent      STAFF       STAFFNO
2019-06-11 09:50:00 12445678        Bob   Not-found     Jon 
2019-06-11 09:46:00 12997865        Alex      Don          Not-found
2019-06-11 09:45:00 12776547        Alice    Alice        Not-found
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 11:22:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434128#M170669</guid>
      <dc:creator>spnewashik</dc:creator>
      <dc:date>2019-06-19T11:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434129#M170670</link>
      <description>&lt;P&gt;In that case you need to include a &lt;CODE&gt;fillnull&lt;/CODE&gt; statement as follows :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  (index=cim source=A) OR (index=cim source=B) OR (index=cim source=C) 
 | rename CALLERNO AS Cell CALLEDNO AS Cell
 | stats latest(_time) as _time, values(Agent) as Agent, values(STAFF) as STAFF by Cell
| fillnull value="Not-found"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 11:26:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434129#M170670</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T11:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434130#M170671</link>
      <description>&lt;P&gt;the problem is here, the same field name exist in Source-B and Source-C which is "CALLERNO". &lt;BR /&gt;
I want to match the value of "Cell" from source-A with other two source . I don't care about the value of "CALLERNO" from source-C while i need to match with field "CALLEDNO" of source-C. &lt;BR /&gt;
So when I rename the both the field "CALLERNO" &amp;amp; CALLEDNO as "Cell" according to your code, it can't match. &lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 11:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434130#M170671</guid>
      <dc:creator>spnewashik</dc:creator>
      <dc:date>2019-06-19T11:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434131#M170672</link>
      <description>&lt;P&gt;Well, you never mentioned before that source C also has a CallerNO field. What if you move the coalesce items around a bit (and add the fillnull which I indeed forgot):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=cim
 | eval Cell = coalesce(Cell,CALLEDNO,CALLERNO)
 | stats latest(_time) values(agent) as agent values(STAFF) as caller_staff values(STAFFNO) as called_staff by Cell
 | fillnull value="Not-found"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or does source B also have a CALLEDNO? If so, you'll need to use a case statement, to set the Cell value based on the source:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=cim
 | eval Cell = case(source="A",Cell,source="B",CALLERNO,source="C",CALLEDNO)
 | stats latest(_time) values(agent) as agent values(STAFF) as caller_staff values(STAFFNO) as called_staff by Cell
 | fillnull value="Not-found"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 11:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434131#M170672</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-19T11:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434132#M170673</link>
      <description>&lt;P&gt;@spnewashik, I see, you should be able to solve this by creating an alias for your fields:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/Knowledge/Addaliasestofields"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.0/Knowledge/Addaliasestofields&lt;/A&gt;&lt;BR /&gt;
Make sure the alias is the same for all (and only) the fields you want to use for your join lets call it for example &lt;CODE&gt;cell_final&lt;/CODE&gt;. &lt;BR /&gt;
Once you have that fields aliases for the three sources, the rest is very easy and your query should look like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=cim source=A) OR (index=cim source=B) OR (index=cim source=C) 
  | stats latest(_time) as _time, values(Agent) as Agent, values(STAFF) as STAFF by cell_final
 | fillnull value="Not-found"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will make things much easier for you.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 12:42:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434132#M170673</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T12:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434133#M170674</link>
      <description>&lt;P&gt;If you only want to link entries that happen at the same time, try it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=cim
  | eval Cell = case(source="A",Cell,source="B",CALLERNO,source="C",CALLEDNO)
  | stats values(agent) as agent values(STAFF) as caller_staff values(STAFFNO) as called_staff by _time,Cell
  | fillnull value="Not-found"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 13:29:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434133#M170674</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-19T13:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434134#M170675</link>
      <description>&lt;P&gt;thanks @DavidHourani..........Field Alias is more convenient in my case. I have created a field alias with the value of Cell (source A), CALLERNO (source B), CALLEDNO (source C) and the final field name is "Contact". The command I applied:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=cim source=A) OR (index=cim source=B) OR (index=cim source=C) | fillnull value="not found"| stats latest(_time) as _time, values(Agent) as Agent, values(STAFF) as STAFF, values(STAFFNO) as STAFFNO by "Contact"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I am facing one problem with ur command- it matches the data  accurately with source B &amp;amp; C but the value of Agent from source A become "Not-found" in the table which should not be, also it shows a value like below :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;time                    Contact       Agent     STAFF      STAFFNO
2019-06-11 09:50:00 12445678        Not found   Not-found      Jon 
                                       Jami
2019-06-11 09:46:00 12997865        Alex         Don             Mart
                                                                Not-found

2019-06-11 09:45:00 12776547        Alice       Alice          Not-found
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't understand what is wrong I have done. &lt;BR /&gt;
Then I tried this command and it shows accurately what I expected: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cim source=A |join Contact type=left    [search  source=B OR source=C | fields _time,Contact,Agent,STAFF,STAFFNO] | fillnull value="not found" | table _time,Contact,Agent,STAFF,STAFFNO

time                    Contact     Agent       STAFF      STAFFNO
2019-06-11 09:50:00 12445678        Mark        Not-found      Jon 
2019-06-11 09:46:00 12997865        Alex         Don           Mart
2019-06-11 09:45:00 12776547        Alice       Alice        Not-found
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks David.....your suggestion for creating Field Alias solve my problem. If you have any more suggestion for me please share. &lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 02:50:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434134#M170675</guid>
      <dc:creator>spnewashik</dc:creator>
      <dc:date>2019-06-20T02:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to match events from 3 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434135#M170676</link>
      <description>&lt;P&gt;Glad to know I could help! Your command looks great.&lt;/P&gt;

&lt;P&gt;If you want to use the &lt;CODE&gt;stats&lt;/CODE&gt;command instead, this should give you better results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=cim source=A) OR (index=cim source=B) OR (index=cim source=C) | stats latest(_time) as _time, values(Agent) as Agent, values(STAFF) as STAFF, values(STAFFNO) as STAFFNO by "Contact"| fillnull value="not found"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if it works out for you! And please accept and upvote if its helpful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 04:19:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-events-from-3-different-sources/m-p/434135#M170676</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-20T04:19:35Z</dc:date>
    </item>
  </channel>
</rss>

