<?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: Most recent event per host ( | Head 1)? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99023#M25564</link>
    <description>&lt;P&gt;This should help:&lt;/P&gt;

&lt;P&gt;Look in the comments of the answer to see gkanapathy's reply...similar to what you are thinking but look at his.&lt;BR /&gt;
&lt;A href="http://splunk-base.splunk.com/answers/22564/finding-last-event"&gt;http://splunk-base.splunk.com/answers/22564/finding-last-event&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Different approach:&lt;BR /&gt;
&lt;A href="http://splunk-base.splunk.com/answers/52891/most-recent-event-from-each-source"&gt;http://splunk-base.splunk.com/answers/52891/most-recent-event-from-each-source&lt;/A&gt; &lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2012 14:11:08 GMT</pubDate>
    <dc:creator>sdaniels</dc:creator>
    <dc:date>2012-10-23T14:11:08Z</dc:date>
    <item>
      <title>Most recent event per host ( | Head 1)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99022#M25563</link>
      <description>&lt;P&gt;So I need to pull only the most recent event from each of 60+ hosts, and put them in a table.&lt;BR /&gt;&lt;BR /&gt;
I'm thinking something like " ...| head 1 per host "   would do the job.  Any thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 13:54:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99022#M25563</guid>
      <dc:creator>marquiselee</dc:creator>
      <dc:date>2012-10-23T13:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent event per host ( | Head 1)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99023#M25564</link>
      <description>&lt;P&gt;This should help:&lt;/P&gt;

&lt;P&gt;Look in the comments of the answer to see gkanapathy's reply...similar to what you are thinking but look at his.&lt;BR /&gt;
&lt;A href="http://splunk-base.splunk.com/answers/22564/finding-last-event"&gt;http://splunk-base.splunk.com/answers/22564/finding-last-event&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Different approach:&lt;BR /&gt;
&lt;A href="http://splunk-base.splunk.com/answers/52891/most-recent-event-from-each-source"&gt;http://splunk-base.splunk.com/answers/52891/most-recent-event-from-each-source&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 14:11:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99023#M25564</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2012-10-23T14:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent event per host ( | Head 1)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99024#M25565</link>
      <description>&lt;P&gt;this works but is inefficient/slow.  The problem is that 1/2 of the hosts are performing a vast majority of the cumulative task (millions) while other host can go days without performing even one task (hence no log event).  &lt;/P&gt;

&lt;P&gt;Id prefer it if it stopped searching against a host's log once the most recent event has been discovered.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 14:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99024#M25565</guid>
      <dc:creator>marquiselee</dc:creator>
      <dc:date>2012-10-23T14:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent event per host ( | Head 1)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99025#M25566</link>
      <description>&lt;P&gt;I was looking through all the Q/A regarding this question (and there are quite a few) and combining a couple suggestions, I tried this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;  | eval lastseen=strftime(_time, "%b %d %Y %H:%M:%S") | stats first(lastseen) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(I'm on 6.5 for reference)&lt;/P&gt;

&lt;P&gt;It makes a table as below (sorry for the formatting).  Of course you can rename the columns as well: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host        first(lastseen) 
1.1.2.245   Jun 10 2017 21:56:21
1.1.255.1   Jun 16 2017 13:41:43
1.1.2.5     Jun 16 2017 10:35:29
1.2.1.1     Jun 16 2017 10:58:05
1.6.10.1    Jun 15 2017 07:36:17
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That seems to be something like what you may want as well...&lt;/P&gt;

&lt;P&gt;EDIT:&lt;/P&gt;

&lt;P&gt;Adding some other conditions, enables you to turn it into a nicely formatted alert:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval lastseen=strftime(_time, "%b %d %Y %H:%M:%S") | eval since=now()-_time | search since&amp;lt;10800 | stats first(lastseen) by host | rename first(lastseen) as "Last Heard From On"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;10800 is three hours BTW.  Set that time to whatever you want and the alert frequency and you should be good to go.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 18:05:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99025#M25566</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2017-06-16T18:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent event per host ( | Head 1)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99026#M25567</link>
      <description>&lt;P&gt;An alert like this would be better&lt;/P&gt;

&lt;P&gt;index=* [inputlookup SourceInactivos.csv | fields Equipo | rename Equipo as source]&lt;BR /&gt;
| table host  _time&lt;BR /&gt;
| eval dif=(now()-_time)/3600&lt;BR /&gt;
| stats first(dif) AS Diferencia by host source&lt;BR /&gt;
| sort 0 -Diferencia&lt;BR /&gt;
| where Diferencia&amp;gt;3&lt;/P&gt;

&lt;P&gt;whit this you can alert those asset that have not sent logs during the las 3 hours&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99026#M25567</guid>
      <dc:creator>elmiguelo123</dc:creator>
      <dc:date>2020-09-29T21:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Most recent event per host ( | Head 1)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99027#M25568</link>
      <description>&lt;P&gt;I had to do a task very similar to this.  I had to find the last mode of each district.  I used the stats command as seen below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a sourcetype=b MODE_CHANGE
| rename 
CONTENT.m:DISTRICT_NAME AS district, 
CONTENT.m:INSTANCE_MODE as mode,  
CONTENT.m:ALERT_TYPE as type
| stats latest(mode) AS latestMode, latest(district) as latestDistrict, latest(type) as latestType by district
| lookup subDivLookup.csv SubDiv_Name as district OUTPUT SubDiv_ID

| table district SubDiv_ID latestMode latestType  
| sort + district
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In my instance there is a ALERT_TYPE that denotes a MODE_CHANGE has occurred.  I am using the 'MODE_CHANGE' string after the sourcetype to filter for just these events.  From there it is just a stats command to get the latest entry. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:14:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Most-recent-event-per-host-Head-1/m-p/99027#M25568</guid>
      <dc:creator>l0gik</dc:creator>
      <dc:date>2020-09-30T02:14:32Z</dc:date>
    </item>
  </channel>
</rss>

