<?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 Most recent set of events in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84163#M17474</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Some time ago I was looking for a way to search for &lt;A href="http://splunk-base.splunk.com/answers/40186/last-events-in-a-timeframe"&gt;events grouped around a date&lt;/A&gt; but I think it was an overkill. I changed the format of my events to include a creation time which is a timestamp (epoch) identical for all events which happened "at the same time".&lt;/P&gt;

&lt;P&gt;What would be the splunk way to search for "events where TIMESTAMP=max(all TIMESTAMPs)". In other words I have, say, 3 groups of 100 events with a unique timestamp per group. I would like to display only the 100 events of the last group which has the largest timestamp.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 05 Mar 2012 15:22:13 GMT</pubDate>
    <dc:creator>wsw70</dc:creator>
    <dc:date>2012-03-05T15:22:13Z</dc:date>
    <item>
      <title>Most recent set of events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84163#M17474</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Some time ago I was looking for a way to search for &lt;A href="http://splunk-base.splunk.com/answers/40186/last-events-in-a-timeframe"&gt;events grouped around a date&lt;/A&gt; but I think it was an overkill. I changed the format of my events to include a creation time which is a timestamp (epoch) identical for all events which happened "at the same time".&lt;/P&gt;

&lt;P&gt;What would be the splunk way to search for "events where TIMESTAMP=max(all TIMESTAMPs)". In other words I have, say, 3 groups of 100 events with a unique timestamp per group. I would like to display only the 100 events of the last group which has the largest timestamp.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2012 15:22:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84163#M17474</guid>
      <dc:creator>wsw70</dc:creator>
      <dc:date>2012-03-05T15:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent set of events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84164#M17475</link>
      <description>&lt;P&gt;Since Splunk always delivers the most recent results first, and since you've set up timestamping for the events to be based on your creation timestamp, you can use streamstats and head to terminate the search as soon as it has seen more than one timestamp:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | streamstats dc(_time) as distinct_times | head (distinct_times == 1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2012 16:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84164#M17475</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2012-03-05T16:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent set of events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84165#M17476</link>
      <description>&lt;P&gt;Thank you - works just great. Would you know if there is a way to access the second last, third last, etc. set of events (based on the same kind of timestamp)?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2012 14:42:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84165#M17476</guid>
      <dc:creator>wsw70</dc:creator>
      <dc:date>2012-03-13T14:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent set of events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84166#M17477</link>
      <description>&lt;P&gt;You can access the second batch by changing the head predicate to &lt;CODE&gt;(distinct_times &amp;lt;= 2)&lt;/CODE&gt;  and follow that with &lt;CODE&gt;| search distinct_times = 2&lt;/CODE&gt; to pick the second batch. The same is true for the n-th set.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2012 15:00:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84166#M17477</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2012-03-13T15:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent set of events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84167#M17478</link>
      <description>&lt;P&gt;This works great, however is there a way to do this split by a variable? What I mean is I have a set of events each with a common time, but for multiple servers. I want to get the latest set of events by server.&lt;/P&gt;

&lt;P&gt;Something like:&lt;/P&gt;

&lt;P&gt;... | streamstats dc(_time) as distinct_times by server | head (distinct_times == 1)&lt;/P&gt;

&lt;P&gt;I have played around with various permutations of the above, but cannot get it to do what I want.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:41:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84167#M17478</guid>
      <dc:creator>nvonkorff</dc:creator>
      <dc:date>2020-09-28T16:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent set of events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84168#M17479</link>
      <description>&lt;P&gt;Great tip! Don't forget you can use the &lt;CODE&gt;reverse&lt;/CODE&gt; command before &lt;CODE&gt;streamstats&lt;/CODE&gt;  as well.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2015 20:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Most-recent-set-of-events/m-p/84168#M17479</guid>
      <dc:creator>bnorthway</dc:creator>
      <dc:date>2015-11-13T20:07:43Z</dc:date>
    </item>
  </channel>
</rss>

