<?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 filter search results by most recent timestamp by host in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262773#M189762</link>
    <description>&lt;P&gt;I want to create a search that will look over the last 30 days of vulnerability events and only retain those events that are from the most recent scan of a host.  I can think of a few ways to do that, but I'm wondering if there is a more efficient way that I'm missing...&lt;/P&gt;

&lt;P&gt;Create a lookup table with the max(_time) and dest and use a lookup+where clause to only retain events where _time=max(_time)&lt;/P&gt;

&lt;P&gt;Use a join command to join the output of a "stats max(_time) by dest" subsearch to the original events and use where to filter them.&lt;/P&gt;

&lt;P&gt;Use a multisearch with one search for the vulnerability events and another that does the "stats max(_time) by dest" and use a transaction to bind them together and then filter with where.&lt;/P&gt;

&lt;P&gt;I could also probably do it with the map command...&lt;/P&gt;

&lt;P&gt;What is the best route to solve this problem?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:15:49 GMT</pubDate>
    <dc:creator>responsys_cm</dc:creator>
    <dc:date>2020-09-29T10:15:49Z</dc:date>
    <item>
      <title>How to filter search results by most recent timestamp by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262773#M189762</link>
      <description>&lt;P&gt;I want to create a search that will look over the last 30 days of vulnerability events and only retain those events that are from the most recent scan of a host.  I can think of a few ways to do that, but I'm wondering if there is a more efficient way that I'm missing...&lt;/P&gt;

&lt;P&gt;Create a lookup table with the max(_time) and dest and use a lookup+where clause to only retain events where _time=max(_time)&lt;/P&gt;

&lt;P&gt;Use a join command to join the output of a "stats max(_time) by dest" subsearch to the original events and use where to filter them.&lt;/P&gt;

&lt;P&gt;Use a multisearch with one search for the vulnerability events and another that does the "stats max(_time) by dest" and use a transaction to bind them together and then filter with where.&lt;/P&gt;

&lt;P&gt;I could also probably do it with the map command...&lt;/P&gt;

&lt;P&gt;What is the best route to solve this problem?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262773#M189762</guid>
      <dc:creator>responsys_cm</dc:creator>
      <dc:date>2020-09-29T10:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter search results by most recent timestamp by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262774#M189763</link>
      <description>&lt;P&gt;I would do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;My Big Broad Search Here | append [
    My Scan Search Here | dedup _time host | rename _time AS lastScanTime | eval DropMe="YES" ]
| eventstats first(lastScanTime) AS lastScanTime BY host
| where _time &amp;gt;= lastScanTime AND isnull(DropMe)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Jul 2016 21:27:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262774#M189763</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-15T21:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter search results by most recent timestamp by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262775#M189764</link>
      <description>&lt;P&gt;Thanks, woodcock...  I'm curious though...  why use the append command at all?  This search seems to get me what I want:&lt;/P&gt;

&lt;P&gt;sourcetype=nessus:scan | eventstats max(_time) AS lastScan by dest | where _time=lastScan&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:50:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262775#M189764</guid>
      <dc:creator>responsys_cm</dc:creator>
      <dc:date>2016-07-18T18:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter search results by most recent timestamp by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262776#M189765</link>
      <description>&lt;P&gt;I was assuming that the qualifying data (My Scan Search) is in a different dataset than the search data (My Big Broad Search).  If all the data is in the same place, then this is not necessary.  If you don't need to &lt;CODE&gt;join&lt;/CODE&gt; (your word, not mine), then why did you mention it?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:26:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262776#M189765</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-18T20:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter search results by most recent timestamp by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262777#M189766</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search for last 30 day | eval day=relative_time(_time, "@d") | eventstats max(_time) as latest by host | where day=relative_time(latest, "@d")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 21:20:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-search-results-by-most-recent-timestamp-by-host/m-p/262777#M189766</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-18T21:20:02Z</dc:date>
    </item>
  </channel>
</rss>

