<?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: Challenges Joining tables  and returning values from both indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409397#M118107</link>
    <description>&lt;P&gt;Hi lbrhyne,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now [ search index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d | eval user= trim(replace(email, "@domain.com", ""))| fields user ]
| table user department Workstation_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;buth remember that there's a limit of 50,000 on subsearch results.&lt;BR /&gt;
If results are more than 50,000, try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d ) OR (index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now)
 | eval HRuserID = trim(replace(email, "@domain.com", "")) , HRuserID=coalesce(HRuserID,user)
 | stats values(user) values(department) values(Workstation_Name) values(index) AS index BY HRuserID
 | search index=wineventlog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2019 16:05:55 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-07-29T16:05:55Z</dc:date>
    <item>
      <title>Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409395#M118105</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Based on some suggested changes by @jawaharas I was able to successfully lookup the value of &lt;STRONG&gt;user&lt;/STRONG&gt; from the &lt;STRONG&gt;Vantage&lt;/STRONG&gt; sourcetype and match it against the &lt;STRONG&gt;winevetlog&lt;/STRONG&gt; and return only the matched data. However, I could only populate the fields from the &lt;STRONG&gt;Vantage&lt;/STRONG&gt; index and not the &lt;STRONG&gt;wineventlog&lt;/STRONG&gt;. I'm thinking it is due to not having a join in the below code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=identities sourcetype="Vantage" (NOT ee_status="R" NOT ee_status="T") earliest=-1d@d latest=-0d@d
| eval user = trim(replace(email, "@domain.com", ""))
| search [ | search index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now()| fields user | format]
| table user,department,ad_fname,ad_last_name,ee_status, Workstation_Name
| eval fullname = toString(ad_fname) + " " + toString(ad_last_name)
| rename user as "Login ID", ee_status as "HR Employment Status" fullname as "Full Name", department as Department, Workstation_Name as "Device"
| table "Login ID" "Full Name" "HR Employment Status" Department, Device  | sort "Full Name"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In my attempt to add a join in, the below query runs with no errors but returns no data.&lt;BR /&gt;
What i'm attempting to do is return a few fields from both indexes.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d | eval HRuserID = trim(replace(email, "@domain.com", "")) 
| join HRuserID [ | search index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now()]
| where HRuserID=user | stats values(user) values(department) values(Workstation_Name)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 14:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409395#M118105</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-07-29T14:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409396#M118106</link>
      <description>&lt;P&gt;Hi lbrhyne,&lt;BR /&gt;
for me, in the subsearch there isn't the HRuserID field, so the join doesn't run.&lt;BR /&gt;
You should rename in subsearch the user field in HRuserID field.&lt;BR /&gt;
In addition, remeber that subsearches have the 50,000 results limit, so if you have more results in subsearch, they couldn't match.&lt;BR /&gt;
For these reasons and because join is a very slow command I suggest to use a different approach:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d ) OR (index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now)
| eval HRuserID = trim(replace(email, "@domain.com", "")) , HRuserID=coalesce(HRuserID,user)
| stats values(user) values(department) values(Workstation_Name) BY HRuserID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;

&lt;P&gt;P.S.: use always index in your searches.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 14:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409396#M118106</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-07-29T14:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409397#M118107</link>
      <description>&lt;P&gt;Hi lbrhyne,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now [ search index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d | eval user= trim(replace(email, "@domain.com", ""))| fields user ]
| table user department Workstation_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;buth remember that there's a limit of 50,000 on subsearch results.&lt;BR /&gt;
If results are more than 50,000, try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d ) OR (index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now)
 | eval HRuserID = trim(replace(email, "@domain.com", "")) , HRuserID=coalesce(HRuserID,user)
 | stats values(user) values(department) values(Workstation_Name) values(index) AS index BY HRuserID
 | search index=wineventlog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 16:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409397#M118107</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-07-29T16:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409398#M118108</link>
      <description>&lt;P&gt;Thanks again for your help @gcusello! I tried the two suggestions above, but neither would pull back the results I was looking for. I think it may have something to do with OR statement for the two indexes. &lt;BR /&gt;
However, I was able to resolve the issue by using an inner Join.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=identities sourcetype="Vantage" (NOT ee_status="T" NOT ee_status="R") earliest=-1d@d latest=-0d@d
| eval user = trim(replace(email, "@domain1.com", ""))
| join type=inner user [ | search index="wineventlog" sourcetype="WinEventLog:Security" ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064)) earliest=-5m latest=now()]
| table user,department,ad_fname,ad_last_name,ee_status, Workstation_Name,src_ip
| eval fullname = toString(ad_fname) + " " + toString(ad_last_name)
| rename user as "Login ID", ee_status as "HR Employment Status" fullname as "Full Name", department as Department, Workstation_Name as "Device"
| table "Login ID" "Full Name" "HR Employment Status" Department, Device | sort "Full Name"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 18:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409398#M118108</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-07-29T18:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409399#M118109</link>
      <description>&lt;P&gt;Hi lbrhyne,&lt;BR /&gt;
I'm sure that you can solve your problem with join, but I suggest to use additional time to try with my hints because join command is a very slow solution!&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 08:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409399#M118109</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-07-30T08:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409400#M118110</link>
      <description>&lt;P&gt;Hi lbrhyne,&lt;BR /&gt;
If my answer helped you, please accept and/or upvote it!&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 12:29:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409400#M118110</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-07-31T12:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409401#M118111</link>
      <description>&lt;P&gt;Hi @gcusello, I have not had time to dig deeper into why I can't get your solution to work. I think it has something to do with converting the email address to user &lt;CODE&gt;| eval user = trim(replace(email, "@domain1.com", ""))&lt;/CODE&gt;, when doing the lookup, but not sure. Right now the Join is working, although it is slow. When I get time to look further into your suggestion and I get it to work I will most certainly accept and/or upvote it.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 15:11:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409401#M118111</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-07-31T15:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409402#M118112</link>
      <description>&lt;P&gt;Thank you.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 15:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409402#M118112</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-07-31T15:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409403#M118113</link>
      <description>&lt;P&gt;Hi @gcusello, I was finally able to put a  little more time into your tip and was able to get it to work! I agree, your solution ins much faster than a join! Thank again!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="wineventlog" sourcetype="WinEventLog:Security" (earliest=-5m latest=now()) ((EventCode=4624 AND Logon_Type=2 OR Logon_Type=10) OR (EventCode=4625 NOT Sub_Status=0xC0000064 NOT Logon_Type=3)) )  OR 
(index=identities sourcetype="Vantage" (NOT ee_status="A" NOT ee_status="L") earliest=-1d@d latest=-0d@d) | eval hruser = trim(replace(email, "@domain.com", ""))
| eval user=coalesce(user,hruser) | stats values(*) AS * BY user | search hruser=* user=*
| table user,department,ad_fname,ad_last_name,ee_status, Workstation_Name
| eval fullname = (toString(ad_fname) + " " + toString(ad_last_name)) 
| rename user as "Login ID", ee_status as "HR Employment Status" fullname as "Full Name", department as Department, Workstation_Name as "Device"
| where Device!=""
| table "Login ID" "Full Name" "HR Employment Status" Department, Device
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2019 15:50:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409403#M118113</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-08-06T15:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409404#M118114</link>
      <description>&lt;P&gt;For those of you that are interested...&lt;BR /&gt;
Time to complete query's:&lt;/P&gt;

&lt;P&gt;Join = 54 seconds&lt;BR /&gt;
Stats = 19 seconds&lt;/P&gt;

&lt;P&gt;Stats WINS by 3X &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 16:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409404#M118114</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-08-06T16:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges Joining tables  and returning values from both indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409405#M118115</link>
      <description>&lt;P&gt;Thank you for your feedback, surely it will be interesting for many Splunkers!&lt;BR /&gt;
Bye and see next time.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 06:25:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Challenges-Joining-tables-and-returning-values-from-both-indexes/m-p/409405#M118115</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-08-07T06:25:23Z</dc:date>
    </item>
  </channel>
</rss>

