<?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: Need help in framing SPL query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/750578#M242383</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254020"&gt;@RanjiRaje&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The appends definitely aren't needed here, as this runs a search for that data each time in order to do the lookup - instead you could look to do something like this:&lt;/P&gt;&lt;P&gt;Replace the three&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;append&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;branches with a single&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;lookup&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that matches on&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;any&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the three possible keys, then keep the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;latest&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;event per host/IP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| loadjob savedsearch="userid:search:hostslists"
| eval host=upper(host)&lt;BR /&gt;| lookup lookupname Hostname as host OUTPUTNEW Hostname as H1, IP as IP1
| lookup lookupname IP       as host OUTPUTNEW IP       as IP2, Hostname as H2
| lookup lookupname AltName  as host OUTPUTNEW AltName  as A3, IP as IP3, Hostname as H3
| eval Hostname=coalesce(H1,H2,H3), IP=coalesce(IP1,IP2,IP3)
| eval starttime=relative_time(now(),"-10d@d")
| where latest&amp;gt;=starttime&lt;BR /&gt;| stats max(latest) as latest by host, Hostname, IP
| eval "Last event date"=strftime(latest,"%d %b %Y")
| table host Hostname IP "Last event date"&lt;BR /&gt;|&amp;nbsp;rename&amp;nbsp;host&amp;nbsp;AS&amp;nbsp;'&lt;SPAN&gt;Host referred in Splunk'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Let me know how you get on or if any bits need tweaking or explaining &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&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>Mon, 28 Jul 2025 16:10:49 GMT</pubDate>
    <dc:creator>livehybrid</dc:creator>
    <dc:date>2025-07-28T16:10:49Z</dc:date>
    <item>
      <title>Need help in framing SPL query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/750573#M242381</link>
      <description>&lt;DIV&gt;| loadjob &lt;STRONG&gt;savedsearch&lt;/STRONG&gt;="userid:search:hostslists"&lt;/DIV&gt;&lt;DIV&gt;| lookup &lt;STRONG&gt;lookupname&lt;/STRONG&gt; &lt;U&gt;&lt;STRONG&gt;Hostname&lt;/STRONG&gt; &lt;/U&gt;as host OUTPUTNEW Hostname,IP&lt;/DIV&gt;&lt;DIV&gt;| eval Host=upper(host)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;| append&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [| loadjob &lt;STRONG&gt;savedsearch&lt;/STRONG&gt;="userid:search:hostslists"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| lookup &lt;STRONG&gt;lookupname&lt;/STRONG&gt; &lt;U&gt;&lt;STRONG&gt;IP&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;as host OUTPUTNEW IP,Hostname&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| eval Host=upper(host)]&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;| append&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [| loadjob &lt;STRONG&gt;savedsearch&lt;/STRONG&gt;="userid:search:hostslists"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| lookup &lt;STRONG&gt;lookupname&lt;/STRONG&gt; &lt;U&gt;&lt;STRONG&gt;AltName&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;as host OUTPUTNEW AltName,IP,Hostname&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| where AltName != Hostname&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| eval Host=upper(host)]&lt;/DIV&gt;&lt;DIV&gt;| eval starttime=relative_time(now(),"-10d@d"),endtime=relative_time(now(),"-1d@d")&lt;/DIV&gt;&lt;DIV&gt;| convert ctime(latest),ctime(starttime),ctime(endtime)&lt;/DIV&gt;&lt;DIV&gt;| where latest&amp;lt;=endtime AND latest&amp;gt;=starttime&lt;/DIV&gt;&lt;DIV&gt;| rename latest as "Last event date", Host as "Host referred in Splunk"&lt;/DIV&gt;&lt;DIV&gt;| eval Hostname=if('Host referred in Splunk'!='IP','Host referred in Splunk',Hostname)&lt;/DIV&gt;&lt;DIV&gt;| stats count by Hostname,IP,"Host referred in Splunk","Last event date"&lt;/DIV&gt;&lt;DIV&gt;| fields - count&lt;/DIV&gt;&lt;DIV&gt;| dedup IP,Hostname&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In my query I am using the &lt;STRONG&gt;saved search "hostslists"&lt;/STRONG&gt; (it contains list of hosts reporting to splunk along with latest event datetime)&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Lookup "lookupname"&lt;/STRONG&gt; (contains fields: Hostname, AltName,IP)&lt;/DIV&gt;&lt;DIV&gt;Aim: Have to get the list of devices present in lookup which is not reporting for more than 10 days&lt;/DIV&gt;&lt;DIV&gt;Logic: some devices report with "Hostname", some devices reprot with "AltName", few devices report with "IP"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;So, I am checking all the 3 fields and capturing "Last event date"&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;Now, I am facing challenge,&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Hostname&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IP&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt; &lt;STRONG&gt;"Last event date"&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;Host1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ipaddr1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25th July&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(by referring IP)&lt;/DIV&gt;&lt;DIV&gt;Host1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ipaddr1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10th June&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(by referring Hostname)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have 2 different "Last event date" for same "Hostname" &amp;amp; "IP".&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In my report, it is not showing the latest date, but Here I have to consider latest date, I am stuck how to use such logic. Can anyone please help ? Thanks for your response&lt;/DIV&gt;</description>
      <pubDate>Mon, 28 Jul 2025 16:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/750573#M242381</guid>
      <dc:creator>RanjiRaje</dc:creator>
      <dc:date>2025-07-28T16:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in framing SPL query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/750578#M242383</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254020"&gt;@RanjiRaje&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The appends definitely aren't needed here, as this runs a search for that data each time in order to do the lookup - instead you could look to do something like this:&lt;/P&gt;&lt;P&gt;Replace the three&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;append&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;branches with a single&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;lookup&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that matches on&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;any&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the three possible keys, then keep the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;latest&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;event per host/IP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| loadjob savedsearch="userid:search:hostslists"
| eval host=upper(host)&lt;BR /&gt;| lookup lookupname Hostname as host OUTPUTNEW Hostname as H1, IP as IP1
| lookup lookupname IP       as host OUTPUTNEW IP       as IP2, Hostname as H2
| lookup lookupname AltName  as host OUTPUTNEW AltName  as A3, IP as IP3, Hostname as H3
| eval Hostname=coalesce(H1,H2,H3), IP=coalesce(IP1,IP2,IP3)
| eval starttime=relative_time(now(),"-10d@d")
| where latest&amp;gt;=starttime&lt;BR /&gt;| stats max(latest) as latest by host, Hostname, IP
| eval "Last event date"=strftime(latest,"%d %b %Y")
| table host Hostname IP "Last event date"&lt;BR /&gt;|&amp;nbsp;rename&amp;nbsp;host&amp;nbsp;AS&amp;nbsp;'&lt;SPAN&gt;Host referred in Splunk'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Let me know how you get on or if any bits need tweaking or explaining &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&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>Mon, 28 Jul 2025 16:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/750578#M242383</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-07-28T16:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in framing SPL query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751398#M242499</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks a lot for your valuable SPL query. I tried using this but I am facing a challenge.&lt;/P&gt;&lt;P&gt;Some of the devices listed in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;lookup file&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;not reported in Splunk&lt;/STRONG&gt;, and therefore do&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;not appear in the savedsearch results&lt;/STRONG&gt;. Ideally, these devices should still be listed in the final output, but that’s not happening.&lt;/P&gt;&lt;P&gt;Could you please suggest a workaround to ensure that&amp;nbsp;those devices are also reflected in the result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks .&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 10:55:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751398#M242499</guid>
      <dc:creator>RanjiRaje</dc:creator>
      <dc:date>2025-08-12T10:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in framing SPL query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751399#M242500</link>
      <description>&lt;P&gt;Try adding this after the where command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup lookupname append=t&lt;/LI-CODE&gt;&lt;P&gt;This assumes that the fields&amp;nbsp;host, Hostname, IP are fields are in your lookup, otherwise you will have to set these up before the stats command&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 11:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751399#M242500</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-08-12T11:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in framing SPL query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751401#M242501</link>
      <description>&lt;P&gt;Hello sir, thanks for the suggestion. But it didn't work as expected. It just appending all the devices from lookup. I need to append only the devices for which there is no entry in savedsearch&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 12:20:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751401#M242501</guid>
      <dc:creator>RanjiRaje</dc:creator>
      <dc:date>2025-08-12T12:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in framing SPL query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751403#M242502</link>
      <description>&lt;P&gt;Without knowledge of your events and your actual search, it is difficult to say what is not working. However, it is possible that after the stats by host etc., you then need to add a where command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where isnull(latest)&lt;/LI-CODE&gt;&lt;P&gt;Or if that doesn't work, try adding this after the inputlookup&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval latest=coalesce(latest,0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and this after the stats&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where latest=0&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Aug 2025 13:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-framing-SPL-query/m-p/751403#M242502</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-08-12T13:02:24Z</dc:date>
    </item>
  </channel>
</rss>

