<?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: Search an index for two fields and join data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-and-join-data/m-p/703885#M238549</link>
    <description>&lt;P&gt;Compared with some of your previous questions on the same subject, this is much clearer. &amp;nbsp;In&amp;nbsp;&lt;A class="" href="https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-with-a-join/m-p/703424#M238416" target="_blank" rel="noopener"&gt;Re: Search an index for two fields with a join&lt;/A&gt;, I gave an example based on speculation that description was unimportant. &amp;nbsp;Now that you illustrate expected results, I no longer have to read your mind. &amp;nbsp;The illustrated results also implies that there can be a different format in description, and that fields first and last are all lower-case, while name in description uses the first-cap rule. &amp;nbsp;So, instead of using the second search as subsearch to limit the first search, simply append output from second search and do stats on events from both.&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=collect_identities sourcetype=ldap:query
    [ search index=db_mimecast splunkAccountCode=* mcType=auditLog
    |fields user
    | dedup user
    | eval email=user, extensionAttribute10=user, extensionAttribute11=user
    | fields email extensionAttribute10 extensionAttribute11
    | format "(" "(" "OR" ")" "OR" ")" 
    ]
| dedup email
| append
    [search index=db_service_now sourcetype="snow:incident" affect_dest="STL Leaver"
    | dedup description
    | rex field=description "Leaver Request for (?&amp;lt;first&amp;gt;\S+) (?&amp;lt;last&amp;gt;\S+) -"
    | rex field=description "(?&amp;lt;first&amp;gt;\S+) (?&amp;lt;last&amp;gt;\S+) Offboarding on -"
    | eval first = lower(first), last = lower(last)
    ]
| eval identity=replace(identity, "Adm0", "")
| eval identity=replace(identity, "Adm", "")
| eval identity=lower(identity)
| fields identity	email	extensionattribute10	extensionattribute11	first	last	_time	affect_dest	active	description	dv_state	number
| stats 
     values(*) as * min(_time) as _time
     BY first last&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Nov 2024 06:44:55 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-11-08T06:44:55Z</dc:date>
    <item>
      <title>Search an index for two fields and join data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-and-join-data/m-p/703808#M238512</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Good day,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to figure out how I can join two searches to see if there is a service now ticket open for someone leaving the company and if that person is still signing into some of our platforms.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is to get the signin details into the platform - as users might have multiple email addresses I want them all.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=collect_identities sourcetype=ldap:query [ search index=db_mimecast splunkAccountCode=* mcType=auditLog
  |fields user
  | dedup user
  | eval email=user, extensionAttribute10=user, extensionAttribute11=user
  | fields email extensionAttribute10 extensionAttribute11
  | format "(" "(" "OR" ")" "OR" ")" 
  ]
| dedup email
| eval identity=replace(identity, "Adm0", "")
| eval identity=replace(identity, "Adm", "")
| eval identity=lower(identity)
| table email extensionAttribute10 extensionAttribute11 first last identity
| stats 
     values(email) AS email
     values(extensionAttribute10) AS extensionAttribute10
     values(extensionAttribute11) AS extensionAttribute11
     values(first) AS first
     values(last) AS last
     BY identity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is to check all leavers in service now&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=db_service_now sourcetype="snow:incident" affect_dest="STL Leaver" 
| dedup description
| table _time affect_dest active description dv_state number&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfortunately the Supporthub does not add the email in the description and only user names and surnames.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I would need to search the first queries 'first' 'last' against the second query to find leavers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;this is what I tried but it does not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=collect_identities sourcetype=ldap:query [ search index=db_mimecast splunkAccountCode=* mcType=auditLog
  |fields user
  | dedup user
  | eval email=user, extensionAttribute10=user, extensionAttribute11=user
  | fields email extensionAttribute10 extensionAttribute11
  | format "(" "(" "OR" ")" "OR" ")" 
  ]
    [search index=db_service_now sourcetype="snow:incident" affect_dest="STL Leaver"
    | dedup description
    | rex field=description "*(?&amp;lt;first&amp;gt;\S+) (?&amp;lt;last&amp;gt;\S+)*"
    | fields first last]
| dedup email
| eval identity=replace(identity, "Adm0", "")
| eval identity=replace(identity, "Adm", "")
| eval identity=lower(identity)
| stats 
     values(email) AS email
     values(extensionAttribute10) AS extensionAttribute10
     values(extensionAttribute11) AS extensionAttribute11
     values(first) AS first
     values(last) AS last
     BY identity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Search one results&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;identity&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;email&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;extensionattribute10&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;extensionattribute11&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;first&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;last&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;nsurname&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;name.surname@domain.com&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;nsurnameT1@domain.com&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;name.surname@consultant.com&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;name&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;surname&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Search two will get all my tickets that was created for people leaving my company and will return results like this&lt;/P&gt;&lt;TABLE border="1" width="100.00000000000001%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;_time&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;affect_dest&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;active&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;description&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;dv_state&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;&lt;SPAN&gt;2024-10-31 09:46:55&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;STL Leaver&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;true&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;Leaver Request for Name Surname - 31/10/2024&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;active&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;INC01&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;So the only way of searching would by to search the second query's description field where first and last appear&lt;BR /&gt;&lt;BR /&gt;Expectations&lt;/P&gt;&lt;TABLE border="1" width="191.66666666666666%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;identity&lt;/TD&gt;&lt;TD width="17.20394000447728%" height="25px"&gt;email&lt;/TD&gt;&lt;TD width="16.129393328856057%" height="25px"&gt;extensionattribute10&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;extensionattribute11&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;first&lt;/TD&gt;&lt;TD width="8.333333333333334%" height="25px"&gt;last&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;_time&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;affect_dest&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;active&lt;/TD&gt;&lt;TD width="14.181777479292592%"&gt;description&lt;/TD&gt;&lt;TD width="19.151555854040744%"&gt;dv_state&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;nsurname&lt;/TD&gt;&lt;TD width="17.20394000447728%" height="25px"&gt;name.surname@domain.com&lt;/TD&gt;&lt;TD width="16.129393328856057%" height="25px"&gt;nsurnameT1@domain.com&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;name.surname@consultant.com&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;name&lt;/TD&gt;&lt;TD width="8.333333333333334%" height="25px"&gt;surname&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;&lt;SPAN&gt;2024-10-31 09:46:55&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;STL Leaver&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;true&lt;/TD&gt;&lt;TD width="14.181777479292592%"&gt;Leaver Request for Name Surname - 31/10/2024&lt;/TD&gt;&lt;TD width="19.151555854040744%"&gt;active&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;INC01&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;jdoe&lt;/TD&gt;&lt;TD width="17.20394000447728%"&gt;john.doe@domain.com&lt;/TD&gt;&lt;TD width="16.129393328856057%"&gt;jdoeT1@domain.com&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;jdoe@worker.com&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;john&lt;/TD&gt;&lt;TD width="8.333333333333334%"&gt;doe&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;&lt;SPAN&gt;2024-11-11 12:46:55&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;STL Leaver&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;true&lt;/TD&gt;&lt;TD width="14.181777479292592%"&gt;John Doe Offboarding on&amp;nbsp; - 31/12/2024&lt;/TD&gt;&lt;TD width="19.151555854040744%"&gt;active&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;INC02&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 07 Nov 2024 13:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-and-join-data/m-p/703808#M238512</guid>
      <dc:creator>JandrevdM</dc:creator>
      <dc:date>2024-11-07T13:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Search an index for two fields and join data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-and-join-data/m-p/703885#M238549</link>
      <description>&lt;P&gt;Compared with some of your previous questions on the same subject, this is much clearer. &amp;nbsp;In&amp;nbsp;&lt;A class="" href="https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-with-a-join/m-p/703424#M238416" target="_blank" rel="noopener"&gt;Re: Search an index for two fields with a join&lt;/A&gt;, I gave an example based on speculation that description was unimportant. &amp;nbsp;Now that you illustrate expected results, I no longer have to read your mind. &amp;nbsp;The illustrated results also implies that there can be a different format in description, and that fields first and last are all lower-case, while name in description uses the first-cap rule. &amp;nbsp;So, instead of using the second search as subsearch to limit the first search, simply append output from second search and do stats on events from both.&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=collect_identities sourcetype=ldap:query
    [ search index=db_mimecast splunkAccountCode=* mcType=auditLog
    |fields user
    | dedup user
    | eval email=user, extensionAttribute10=user, extensionAttribute11=user
    | fields email extensionAttribute10 extensionAttribute11
    | format "(" "(" "OR" ")" "OR" ")" 
    ]
| dedup email
| append
    [search index=db_service_now sourcetype="snow:incident" affect_dest="STL Leaver"
    | dedup description
    | rex field=description "Leaver Request for (?&amp;lt;first&amp;gt;\S+) (?&amp;lt;last&amp;gt;\S+) -"
    | rex field=description "(?&amp;lt;first&amp;gt;\S+) (?&amp;lt;last&amp;gt;\S+) Offboarding on -"
    | eval first = lower(first), last = lower(last)
    ]
| eval identity=replace(identity, "Adm0", "")
| eval identity=replace(identity, "Adm", "")
| eval identity=lower(identity)
| fields identity	email	extensionattribute10	extensionattribute11	first	last	_time	affect_dest	active	description	dv_state	number
| stats 
     values(*) as * min(_time) as _time
     BY first last&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2024 06:44:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-an-index-for-two-fields-and-join-data/m-p/703885#M238549</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-11-08T06:44:55Z</dc:date>
    </item>
  </channel>
</rss>

