<?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: Fields from  lookup with Join missing in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747857#M241906</link>
    <description>&lt;P&gt;So, this is a common pattern and the solution is to work your logic like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;```search indexes to get list of servers```
...
| stats max(_time_) as latest count by System
| rename System_Name as System
``` At this point all Systems found will have a count &amp;gt; 0 ```

``` So now add in your control group to the end of the list ```
| inputlookup append=t system_info.csv
``` Now this will "join" the two possible sets of 'System' together ```
| stats values(*) as * max(count) as count by System
``` And any of those with count = 0 are those that came from your
    lookup control and this gives you the ones not found in your data ```
| where count=0&lt;/LI-CODE&gt;&lt;P&gt;The final where clause will cause only the missing items to show, but you can of course do what you need there with any time calculations based on the latest value from the top search.&lt;/P&gt;&lt;P&gt;You can if you want use the lookup as a subsearch contstraint on the outer search so that it finds ONLY those in the lookup, as opposed to all systems, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=servers sourcetype=logs [ 
  | inputlookup system_info.csv 
  | fields System 
  | rename System as System_Name
]
...&lt;/LI-CODE&gt;&lt;P&gt;Note that this assumes your data contains a field called System_Name, but your field in the lookup is System.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jun 2025 22:24:23 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2025-06-11T22:24:23Z</dc:date>
    <item>
      <title>Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747770#M241879</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a query that detects missing systems.&amp;nbsp; the lookup table has fields System, Location, responsible.&lt;BR /&gt;&lt;BR /&gt;I am trying to get the location and responsible to show in the end result.&amp;nbsp; It appears the join is losing those values.&amp;nbsp; &amp;nbsp;Is there a way to get those values to the final result?&lt;BR /&gt;&lt;BR /&gt;| inputlookup system_info.csv&lt;BR /&gt;| eval System_Name=System&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;| table System_Name&lt;BR /&gt;| join type=left Sensor_Name [| search index=servers sourcetype=logs&lt;BR /&gt;&amp;nbsp; &amp;nbsp; | stats latest(_time) as Time by System_Name&lt;BR /&gt;&amp;nbsp; &amp;nbsp; | eval mytime=strftime(Time,"%Y-%m-%dT%H:%M:%S")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; | sort Time asc | eval now_time = now()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; | eval last_seen_ago_in_seconds = now_time - Time&lt;BR /&gt;&amp;nbsp; &amp;nbsp; | sort -last_seen_ago_in_seconds ]&lt;BR /&gt;| stats values(*) as * by System&lt;/SPAN&gt;&lt;SPAN&gt;_Name&lt;BR /&gt;| eval MISSING = if(isnull(last_seen_ago_in_seconds) OR last_seen_ago_in_seconds&amp;gt;7200,"MISSING","GOOD")&lt;BR /&gt;| where MISSING=="MISSING"&lt;BR /&gt;| table System&lt;/SPAN&gt;&lt;SPAN&gt;_Name Location Responsible MISSING&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 22:59:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747770#M241879</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-06-10T22:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747771#M241880</link>
      <description>&lt;P&gt;Firstly, join is not a good way to do things in Splunk - it has limitations and can almost always be avoided by using stats and&amp;nbsp;your search pattern is not how you would combine search and lookup elements.&lt;/P&gt;&lt;P&gt;You are discarding Location and Responsible from the lookup because of your table statements line 3.&lt;/P&gt;&lt;P&gt;Anyway, try this (I removed the unused elements in your search and the double sort in your join).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=servers sourcetype=logs 
| stats latest(_time) as Time by System_Name 
``` Calculate time differences ```
| eval last_seen_ago_in_seconds = now() - Time 
| eval MISSING = if(isnull(last_seen_ago_in_seconds) OR last_seen_ago_in_seconds&amp;gt;7200,"MISSING","GOOD") 
| where MISSING=="MISSING" 
``` Find the Location and Responsible ```
| lookup system_info.csv System as System_Name 

``` Now render the results ```
| table System_Name Location Responsible MISSING
| sort -last_seen_ago_in_seconds&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 23:25:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747771#M241880</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-06-10T23:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747774#M241881</link>
      <description>&lt;P&gt;So let me start by saying I've been struggling with these lookup commands.&lt;BR /&gt;&lt;BR /&gt;My objective here is to use the lookup as it contains all known servers to find the servers that are not logging.&amp;nbsp; Including those that have yet to log.&amp;nbsp; This modified query now gives me the other fields.&amp;nbsp; &amp;nbsp;However, the results are wrong.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In the ned I need to&amp;nbsp; get the list of servers in the lookup that are not in the query results (index=servers sourcetype=logs)&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 03:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747774#M241881</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-06-11T03:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747776#M241883</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/139005"&gt;@cdevoe57&lt;/a&gt;&amp;nbsp; As mentioned by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; Its not best to use join, as it can sometimes cause fields from lookup to be lost. but anyway can you try below if you still want to use join,&lt;BR /&gt;&lt;BR /&gt;| inputlookup system_info.csv&lt;BR /&gt;| eval System_Name=System&lt;BR /&gt;| join type=left System_Name [&lt;BR /&gt;| search index=servers sourcetype=logs&lt;BR /&gt;| stats latest(_time) as Time by System_Name&lt;BR /&gt;| eval mytime=strftime(Time,"%Y-%m-%dT%H:%M:%S")&lt;BR /&gt;| eval now_time = now()&lt;BR /&gt;| eval last_seen_ago_in_seconds = now_time - Time&lt;BR /&gt;]&lt;BR /&gt;| stats values(*) as * by System_Name&lt;BR /&gt;| lookup system_info.csv System_Name OUTPUT Location Responsible&lt;BR /&gt;| eval MISSING = if(isnull(last_seen_ago_in_seconds) OR last_seen_ago_in_seconds&amp;gt;7200,"MISSING","GOOD")&lt;BR /&gt;| where MISSING=="MISSING"&lt;BR /&gt;| table System_Name Location Responsible MISSING&lt;BR /&gt;&lt;BR /&gt;or you can also try and check below, without join.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;index=servers sourcetype=logs&lt;BR /&gt;| stats latest(_time) as Time by System_Name&lt;BR /&gt;| eval last_seen_ago_in_seconds = now() - Time&lt;BR /&gt;| eval MISSING = if(isnull(last_seen_ago_in_seconds) OR last_seen_ago_in_seconds&amp;gt;7200, "MISSING", "GOOD")&lt;BR /&gt;| where MISSING=="MISSING"&lt;BR /&gt;| lookup system_info.csv System_Name OUTPUT Location Responsible&lt;BR /&gt;| table System_Name Location Responsible MISSING last_seen_ago_in_seconds&lt;BR /&gt;| sort -last_seen_ago_in_seconds&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a kudos/Karma. Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 04:14:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747776#M241883</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-06-11T04:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747790#M241885</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/139005"&gt;@cdevoe57&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to use the lookup as a source of truth for the list of hosts I would use the following, also just a note that I'm suggesting tstats here which is *much* more performant than a regular index= search.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats latest(_time) as _time WHERE index=servers sourcetype=logs by host
| eval last_seen_ago_in_seconds = now() - _time
| eval System_Name = host
| append [|inputlookup system_info.csv | eval last_seen_ago_in_seconds=9999]
| stats min(last_seen_ago_in_seconds) as last_seen_ago_in_seconds, values(Location) AS Location, values(Responsible) AS Responsible by System_Name
| eval MISSING = if(isnull(last_seen_ago_in_seconds) OR last_seen_ago_in_seconds&amp;gt;7200, "MISSING", "GOOD")
| where MISSING=="MISSING"
| sort -last_seen_ago_in_seconds&lt;/LI-CODE&gt;&lt;P&gt;This works by appending the system_info.csv with a large&amp;nbsp;last_seen_ago_in_seconds which is updated by a lower&amp;nbsp;last_seen_ago_in_seconds value if the host has been found.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 08:12:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747790#M241885</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-06-11T08:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747815#M241892</link>
      <description>&lt;P&gt;Thanks for the input.&amp;nbsp; In fact, your first solution is what I ended up doing.&amp;nbsp; That one works.&lt;BR /&gt;&lt;BR /&gt;The second solution does not work.&amp;nbsp; &amp;nbsp;The query doesn't have the list of all systems when it calculates the missing&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 12:34:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747815#M241892</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-06-11T12:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747816#M241893</link>
      <description>&lt;P&gt;I had tried your method before&lt;BR /&gt;&lt;BR /&gt;Apparently I screwed up the syntax&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The | lookup system_info.csv System as System_Name line was failing.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 12:37:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747816#M241893</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-06-11T12:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747857#M241906</link>
      <description>&lt;P&gt;So, this is a common pattern and the solution is to work your logic like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;```search indexes to get list of servers```
...
| stats max(_time_) as latest count by System
| rename System_Name as System
``` At this point all Systems found will have a count &amp;gt; 0 ```

``` So now add in your control group to the end of the list ```
| inputlookup append=t system_info.csv
``` Now this will "join" the two possible sets of 'System' together ```
| stats values(*) as * max(count) as count by System
``` And any of those with count = 0 are those that came from your
    lookup control and this gives you the ones not found in your data ```
| where count=0&lt;/LI-CODE&gt;&lt;P&gt;The final where clause will cause only the missing items to show, but you can of course do what you need there with any time calculations based on the latest value from the top search.&lt;/P&gt;&lt;P&gt;You can if you want use the lookup as a subsearch contstraint on the outer search so that it finds ONLY those in the lookup, as opposed to all systems, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=servers sourcetype=logs [ 
  | inputlookup system_info.csv 
  | fields System 
  | rename System as System_Name
]
...&lt;/LI-CODE&gt;&lt;P&gt;Note that this assumes your data contains a field called System_Name, but your field in the lookup is System.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 22:24:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747857#M241906</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-06-11T22:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Fields from  lookup with Join missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747924#M241920</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;points out, join is not the correct approach. &amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;gives a logic that implements your requirements. &amp;nbsp;But the implementation inherits some convoluted logic in your original attempt. (The use of tstats requires that field&amp;nbsp;&lt;EM&gt;System_Name&lt;/EM&gt; is the same as &lt;EM&gt;host&lt;/EM&gt; or is otherwise extracted at index time. &amp;nbsp;But your original SPL seems to imply the opposite. &amp;nbsp;I will not make such assumption below.)&lt;/P&gt;&lt;P&gt;Your original expression&amp;nbsp;&lt;FONT face="andale mono,times"&gt;&lt;SPAN&gt;| eval MISSING = if(isnull(last_seen_ago_in_seconds) OR last_seen_ago_in_seconds&amp;gt;7200,"MISSING","GOOD")&lt;/SPAN&gt;&lt;/FONT&gt; really just says a &lt;U&gt;System&lt;/U&gt; contained in system_info.csv is MISSING if&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;no matching System_Name appears in sourcetype log, or&lt;/LI&gt;&lt;LI&gt;a matching System_name appears in sourcetype log but is more than 2 hours ago.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Is this correct? &amp;nbsp;There should be no need to even evaluate last_seen_ago_in_seconds if you simply filter search with earliest=-2h which is more efficient, too. &amp;nbsp;Additionally, the field MISSING is unnecessary in the table because it will always have value "MISSING" according to your logic.&lt;/P&gt;&lt;P&gt;Here is a much simplified logic:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=servers sourcetype=logs earliest=-2h
| stats latest(_time) as Time by System_Name sourcetype
| append
    [inputlookup system_info.csv
    | fields System Location Responsible
``` ^^^ only necessary if there are more than these three fields ```
    | rename System as System_Name]
| stats values(sourcetype) as _last2hours values(Location) as Location
  values(Responsible) as Responsible by System_Name
| where isnull(_last2hours)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 06:10:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-from-lookup-with-Join-missing/m-p/747924#M241920</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-06-13T06:10:54Z</dc:date>
    </item>
  </channel>
</rss>

