<?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 Get the 10 recent events for each host. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679032#M232124</link>
    <description>&lt;P&gt;I am trying to write a search that will pull the 10 (or so) most recent events for each host. The tail and head commands apparently do not allow any grouping, and I am trying to wrap my head around how to do this.&lt;/P&gt;&lt;P&gt;I know this does not work, but this is what I am looking for:&lt;/P&gt;&lt;PRE&gt;index=index1&lt;BR /&gt;| head 10 by host&lt;/PRE&gt;&lt;P&gt;The closest I can come up with is:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;index=index1&lt;BR /&gt;| stats values(_raw) by host&lt;/PRE&gt;&lt;P&gt;But that still gives me everything in the time range, not just the last 10 events per host.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 16:50:49 GMT</pubDate>
    <dc:creator>allen_hunter</dc:creator>
    <dc:date>2024-02-28T16:50:49Z</dc:date>
    <item>
      <title>Get the 10 recent events for each host.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679032#M232124</link>
      <description>&lt;P&gt;I am trying to write a search that will pull the 10 (or so) most recent events for each host. The tail and head commands apparently do not allow any grouping, and I am trying to wrap my head around how to do this.&lt;/P&gt;&lt;P&gt;I know this does not work, but this is what I am looking for:&lt;/P&gt;&lt;PRE&gt;index=index1&lt;BR /&gt;| head 10 by host&lt;/PRE&gt;&lt;P&gt;The closest I can come up with is:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;index=index1&lt;BR /&gt;| stats values(_raw) by host&lt;/PRE&gt;&lt;P&gt;But that still gives me everything in the time range, not just the last 10 events per host.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 16:50:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679032#M232124</guid>
      <dc:creator>allen_hunter</dc:creator>
      <dc:date>2024-02-28T16:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get the 10 recent events for each host.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679035#M232125</link>
      <description>&lt;P&gt;This seems to work, but feels a little "hack-ish":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;index=txdir_mainframe &lt;BR /&gt;| transaction host maxevents=20&lt;BR /&gt;| dedup host&lt;/PRE&gt;&lt;P&gt;If anyone has any better ideas, I am open to suggestions.&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 17:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679035#M232125</guid>
      <dc:creator>allen_hunter</dc:creator>
      <dc:date>2024-02-28T17:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get the 10 recent events for each host.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679043#M232127</link>
      <description>&lt;P&gt;There are couple of other ways to do that.&amp;nbsp; I like the &lt;FONT face="courier new,courier"&gt;dedup&lt;/FONT&gt; command because it's simple.&amp;nbsp; It retains the most recent n events by the specified field(s).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = index1
| dedup 10 host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This method is for those who dislike dedup.&amp;nbsp; It counts events by host and then takes those with a count &amp;lt;=10.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = index1
| streamstats count by host
| where count &amp;lt;= 10
| fields - count&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 28 Feb 2024 17:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679043#M232127</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-02-28T17:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get the 10 recent events for each host.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679051#M232131</link>
      <description>&lt;P&gt;I did not know you could add a count to the dedup statement. This is good info to know.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I completely forgot about trying the streamstats method. But I have used it in the past. Will put it in my notes for future reference.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 19:57:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-the-10-recent-events-for-each-host/m-p/679051#M232131</guid>
      <dc:creator>allen_hunter</dc:creator>
      <dc:date>2024-02-28T19:57:04Z</dc:date>
    </item>
  </channel>
</rss>

