<?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 How to combine two lookups? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-lookups/m-p/644246#M223158</link>
    <description>&lt;P&gt;&lt;SPAN&gt;On Splunk, I have the following 2 searches: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`ABC_logs(traffic)` user != "unknown" src_ip IN (*) dest_ip IN (*)
| stats values(src_ip) values(src_zone) values(dest_ip) values(dest_port) values(app) values(transport) values(session_end_reason) values(user) by host rule action | rename values(*) as *
| dedup src_ip, dest_ip
| rename src_ip as device_ip_address
| fields device_ip_address, dest_ip, user, host [search index=DEF sourcetype = asset_registry_2
| dedup device_ip_address | fields device_ip_address, host ]&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;AND &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup laso_lab_networks.csv
| join type=inner LAB_ID
[| inputlookup laso_lab_firewalls.csv
| eval Firewall = split(Firewall, ",")
| mvexpand Firewall]
| dedup Firewall
| eval Firewall = mvindex(split(Firewall, "."), 0)
| fields LAB_ID, Lab_Mgr, Firewall&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I need to write a single query that would LINK both these queries such that the field "Firewall" from search 1 is joined to the field "host" from search 2.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I appreciate any help you can offer&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 14:54:55 GMT</pubDate>
    <dc:creator>POR160893</dc:creator>
    <dc:date>2023-05-23T14:54:55Z</dc:date>
    <item>
      <title>How to combine two lookups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-lookups/m-p/644246#M223158</link>
      <description>&lt;P&gt;&lt;SPAN&gt;On Splunk, I have the following 2 searches: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`ABC_logs(traffic)` user != "unknown" src_ip IN (*) dest_ip IN (*)
| stats values(src_ip) values(src_zone) values(dest_ip) values(dest_port) values(app) values(transport) values(session_end_reason) values(user) by host rule action | rename values(*) as *
| dedup src_ip, dest_ip
| rename src_ip as device_ip_address
| fields device_ip_address, dest_ip, user, host [search index=DEF sourcetype = asset_registry_2
| dedup device_ip_address | fields device_ip_address, host ]&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;AND &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup laso_lab_networks.csv
| join type=inner LAB_ID
[| inputlookup laso_lab_firewalls.csv
| eval Firewall = split(Firewall, ",")
| mvexpand Firewall]
| dedup Firewall
| eval Firewall = mvindex(split(Firewall, "."), 0)
| fields LAB_ID, Lab_Mgr, Firewall&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I need to write a single query that would LINK both these queries such that the field "Firewall" from search 1 is joined to the field "host" from search 2.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I appreciate any help you can offer&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 14:54:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-lookups/m-p/644246#M223158</guid>
      <dc:creator>POR160893</dc:creator>
      <dc:date>2023-05-23T14:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two lookups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-lookups/m-p/644283#M223170</link>
      <description>&lt;P&gt;Both searches are very confusing, and seem overly complicated. &amp;nbsp;I took the liberty to simplify. (With the susbsearch in the main search, the first search should also be more efficient.) But really if a good use of the lookup laso_lab_firewalls.csv is to match host name, I wonder if it is much more efficient to actually produce the lookup with host as one of keys. &amp;nbsp;Lookup is a binary tree, whereas inputlookup forces you to use other, less efficient commands.&lt;/P&gt;&lt;P&gt;Anyway, the main idea is to stitch the two together, then do values operation on non-overlapping fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`ABC_logs(traffic)` user != "unknown" 
    [search index=DEF sourcetype = asset_registry_2
    | dedup device_ip_address | fields device_ip_address, host 
    | rename device_as src_ip]
| stats values(src_ip) values(src_zone) values(dest_ip) values(dest_port) values(app) values(transport) values(session_end_reason) values(user) by host rule action
| rename values(*) as *
| rename src_ip as device_ip_address
| fields device_ip_address, dest_ip, user, host
| append
    [| inputlookup laso_lab_firewalls.csv
    | eval Firewall = split(Firewall, ",")
    | mvexpand Firewall
    | dedup Firewall
    | eval host = mvindex(split(Firewall, "."), 0)
    | fields LAB_ID, Lab_Mgr, host]
| stats values(device_ip_address) as device_ip_address values(dest_ip) as dest_ip values(user) as user values(LAB_ID) as LAB_ID values(Lab_Mgr) as Lab_Mgr by host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 16:34:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-lookups/m-p/644283#M223170</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-23T16:34:30Z</dc:date>
    </item>
  </channel>
</rss>

