<?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 reference same field name from 2 different indexes when correlating ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596107#M207511</link>
    <description>&lt;P&gt;coalesce works on different fields in the same event not the same field in different events&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2022 06:42:01 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-05-02T06:42:01Z</dc:date>
    <item>
      <title>How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596103#M207507</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I need to correlate data from 2 different Indexes wherein the field name is common.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Index=idx1&amp;nbsp; ( This index has general user info)&amp;nbsp;&lt;BR /&gt;Field Name:&amp;nbsp; &lt;STRONG&gt;sys_created_by&lt;/STRONG&gt;&lt;BR /&gt;Value: &amp;lt;email id of the user&amp;gt;&lt;BR /&gt;Other fields in idx1 of interest: &lt;STRONG&gt;login_time&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Index=idx2&amp;nbsp; ( This is the Index which has URLs accessed by the user)&lt;BR /&gt;Field Name:&amp;nbsp; &lt;STRONG&gt;sys_created_by&lt;/STRONG&gt;&lt;BR /&gt;Value: &amp;lt;email id of the user&amp;gt;&lt;BR /&gt;&lt;BR /&gt;The url&amp;nbsp; information is stored in a field called "url" in idx2.&lt;BR /&gt;&lt;BR /&gt;Use case is to take the &lt;STRONG&gt;sys_created_by&lt;/STRONG&gt; field from IDX1&amp;nbsp; and lookup/search for all urls&amp;nbsp; in IDX2&amp;nbsp; accessed by&amp;nbsp; the&amp;nbsp; &amp;nbsp;sys_created_by coming from idx1.&amp;nbsp; &amp;nbsp; I cannot rely on &lt;STRONG&gt;sys_created_by&lt;/STRONG&gt; field from &lt;STRONG&gt;idx2&lt;/STRONG&gt; alone as it doesn't have all the other user attributes that are in IDX1 such as login_time.&amp;nbsp; &amp;nbsp;Hence i need to correlate data across the two indexes.&lt;BR /&gt;&lt;BR /&gt;Do i need to do which will merge the sys_created_by from both indexes ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval common_field = coalesce(sys_created_by, sys_created_by)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I tried something like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=idx1 sys_created_by!="") OR (index=idx2 sys_created_by!="" url!="")
| stats values(url) values(login_time) BY sys_created_by&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this doesn't show results as expected.&amp;nbsp;&lt;BR /&gt;Is there a way to reference my common field like shown below in BY ;&amp;nbsp; to tell Splunk which idx it needs to refer ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(url), values(login_time) BY ( idx2.sys_created_by)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:25:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596103#M207507</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-05-02T06:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596104#M207508</link>
      <description>&lt;P&gt;Your approach of&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=idx1 sys_created_by!="") OR (index=idx2 sys_created_by!="" url!="")
| stats values(url) values(login_time) BY sys_created_by&lt;/LI-CODE&gt;&lt;P&gt;should be exactly what you need. It does not matter that the data has the same field in both indexes, splunk does not care which index the event is from. If sys_created_by="XX" it will be the same for both indexes, so your stats values command will group all urls and login times for XX&lt;/P&gt;&lt;P&gt;What results did it show and why was it unexpected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:32:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596104#M207508</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-05-02T06:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596105#M207509</link>
      <description>&lt;P&gt;Thanks for responding.&amp;nbsp; But do i need to use the coalesce command before the stats command ? Or is the coalesce not required at all and i can directly run the stats ?&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:35:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596105#M207509</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-05-02T06:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596106#M207510</link>
      <description>&lt;P&gt;Coalesce is not needed, there is effectively only one field 'sys_created_by' and it will have a value depending on which index it comes from&lt;/P&gt;&lt;P&gt;Coalesce is used in this scenario, where the field name is different, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval common_field=coalesce(field_from_idx1, field_from_idx2)
| stats xxxx by common_field&lt;/LI-CODE&gt;&lt;P&gt;but you don't need that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:41:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596106#M207510</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-05-02T06:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596107#M207511</link>
      <description>&lt;P&gt;coalesce works on different fields in the same event not the same field in different events&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:42:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596107#M207511</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-05-02T06:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596109#M207512</link>
      <description>&lt;P&gt;Although in the case of two data sets, it would be different fields in different events if only one of the fields is present in each data set. Thereby creating the 'join' field.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596109#M207512</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-05-02T06:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596121#M207517</link>
      <description>&lt;P&gt;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367" target="_self"&gt;&lt;SPAN class=""&gt;bowesmana&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp; /&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;what about the case, when the common_field changes values across indexes ?&lt;BR /&gt;For example:&lt;BR /&gt;In Idx1 ,&amp;nbsp; i have &lt;STRONG&gt;sys_created_by&lt;/STRONG&gt; = &lt;A href="mailto:johnk@domain.com" target="_blank" rel="noopener"&gt;johnk@domain.com&lt;/A&gt;&lt;BR /&gt;In idx2,&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;sys_created_by&lt;/STRONG&gt; = &lt;A href="mailto:some_other@domain.com" target="_blank" rel="noopener"&gt;some_other_user@domain.com&lt;/A&gt;&amp;nbsp; but &lt;STRONG&gt;user_email&lt;/STRONG&gt;=johnk@domain.com&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If i want to do a stats grouping for &lt;A href="mailto:johnk@domain.com" target="_blank" rel="noopener"&gt;johnk@domain.com&lt;/A&gt; , how to go about this ? The below coalesce command does not show desired results.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&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;| eval common_field= coalesce(sys_created_by, user_email) &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;BR /&gt;common_field ends up showing the value of &lt;A href="mailto:some_other_user@domain.com" target="_blank" rel="noopener"&gt;some_other_user@domain.com&lt;/A&gt;&amp;nbsp;.&lt;BR /&gt;&lt;BR /&gt;But&amp;nbsp; my requirement is to grab &lt;A href="mailto:johnk@domain.com" target="_blank" rel="noopener"&gt;johnk@domain.com&lt;/A&gt;&amp;nbsp;into some common field and leverage it further to stats group by .&lt;BR /&gt;Pls advise.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 08:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596121#M207517</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-05-02T08:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference same field name from 2 different indexes when correlating ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596201#M207545</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to decide which data (john@) is important and which field that comes from.&lt;/P&gt;&lt;P&gt;If your data has&lt;/P&gt;&lt;P&gt;idx1 (sys_created_by)&lt;/P&gt;&lt;P&gt;idx2 (sys_created_by and user_email)&lt;/P&gt;&lt;P&gt;then IFF user_email contains the DATA that is important to your grouping, then as idx1 does NOT contain that field, you would use any one of these three constructs (all will produce the same outcome)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval group_by_field=coalesce(user_email, sys_created_by)
| eval group_by_field=if(isnotnull(user_email), user_email, sys_created_by)
| eval group_by_field=if(index="idx2", user_email, sys_created_by)&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 23:27:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reference-same-field-name-from-2-different-indexes-when/m-p/596201#M207545</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-05-02T23:27:37Z</dc:date>
    </item>
  </channel>
</rss>

