<?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: subsearch in a stats command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758432#M243282</link>
    <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=dhcp dhcp_type IN (DHCPACK DHCPOFFER) NOT (dest_hostname IN (PC* LP* GIS* MU* iPhone* iPad*))
| stats earliest(_time) AS FirstTime by dest_mac dest_hostname dest_ip
| where FirstTime &amp;gt; relative_time(now(), "-30d@d")
| stats earliest(_time) AS FirstTime earliest(dest_hostname) as dest_hostname earliest(dest_ip) as dest_ip by dest_mac
| convert ctime(FirstTime)
| `LOOKUP_OUI(dest_mac)`&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 17 Feb 2026 18:02:08 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2026-02-17T18:02:08Z</dc:date>
    <item>
      <title>subsearch in a stats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758430#M243281</link>
      <description>&lt;P&gt;I'm using this command to search dhcp logs and find devices that are new in the last 30 days other than a list of expected hostnames:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=dhcp dhcp_type IN (DHCPACK DHCPOFFER) NOT (dest_hostname IN (PC* LP* GIS* MU* iPhone* iPad*))
| stats earliest(_time) AS FirstTime by dest_mac 
| where FirstTime &amp;gt; relative_time(now(), "-30d@d")
| convert ctime(FirstTime)
| `LOOKUP_OUI(dest_mac)`&lt;/LI-CODE&gt;&lt;P&gt;I would like to display the latest dest_hostname and its IP address (dest_ip) by searching again just to populate those fields.&amp;nbsp; I don't want to add them to the stats statement because I don't want to differentiate when IP address or hostname change.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 17:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758430#M243281</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2026-02-17T17:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch in a stats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758432#M243282</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=dhcp dhcp_type IN (DHCPACK DHCPOFFER) NOT (dest_hostname IN (PC* LP* GIS* MU* iPhone* iPad*))
| stats earliest(_time) AS FirstTime by dest_mac dest_hostname dest_ip
| where FirstTime &amp;gt; relative_time(now(), "-30d@d")
| stats earliest(_time) AS FirstTime earliest(dest_hostname) as dest_hostname earliest(dest_ip) as dest_ip by dest_mac
| convert ctime(FirstTime)
| `LOOKUP_OUI(dest_mac)`&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 Feb 2026 18:02:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758432#M243282</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2026-02-17T18:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch in a stats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758435#M243283</link>
      <description>&lt;P&gt;It's close.&amp;nbsp; Changing earliest(dest_hostname) and earliest(dest_ip) to latest(dest_hostname) and latest(dest_ip) gave me what I wanted in those fields, but now FirstTime is blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 18:21:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758435#M243283</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2026-02-17T18:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch in a stats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758436#M243284</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats latest(FirstTime) AS FirstTime latest(dest_hostname) as dest_hostname latest(dest_ip) as dest_ip by dest_mac&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 Feb 2026 18:24:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758436#M243284</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2026-02-17T18:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch in a stats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758437#M243285</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; That did it.&amp;nbsp; I couldn't work out in my head how to make FirstTime part of the second stats output properly.&amp;nbsp; This is the search now with the corrections:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=dhcp dhcp_type IN (DHCPACK DHCPOFFER) NOT (dest_hostname IN (PC* LP* GIS* MU* iPhone* iPad*)) 
| stats  earliest(_time) AS FirstTime BY dest_mac dest_hostname dest_ip
| where FirstTime &amp;gt; relative_time(now(), "-30d@d")
| stats latest(FirstTime) AS FirstTime latest(dest_hostname) AS dest_hostname latest(dest_ip) AS dest_ip BY dest_mac
| convert ctime(FirstTime)
| `LOOKUP_OUI(dest_mac)`&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 Feb 2026 18:35:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-in-a-stats-command/m-p/758437#M243285</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2026-02-17T18:35:10Z</dc:date>
    </item>
  </channel>
</rss>

