<?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 stats latest not returning a value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24501#M4519</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a silly problem.  I can't get stats latest(_time) to return a value.  It's a basic search--just trying to find the last time each host reported in.&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
index=foo | stats latest(_time) by host&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;
earliest(_time) seems to work, and so do the first and last functions, but latest just gives me a blank entry.  What's going on?  If it matters, this is perfmon data and I think it's pretty clean.  It's not just the _time field either; no field I pass to latest is giving me a result.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 11:39:56 GMT</pubDate>
    <dc:creator>cphair</dc:creator>
    <dc:date>2020-09-28T11:39:56Z</dc:date>
    <item>
      <title>stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24501#M4519</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a silly problem.  I can't get stats latest(_time) to return a value.  It's a basic search--just trying to find the last time each host reported in.&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
index=foo | stats latest(_time) by host&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;
earliest(_time) seems to work, and so do the first and last functions, but latest just gives me a blank entry.  What's going on?  If it matters, this is perfmon data and I think it's pretty clean.  It's not just the _time field either; no field I pass to latest is giving me a result.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24501#M4519</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2020-09-28T11:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24502#M4520</link>
      <description>&lt;P&gt;This most definitely seems to be a bug. Others have reported the same problem, so you're not alone. Have a look at &lt;A href="http://splunk-base.splunk.com/answers/42084/latest-function-in-stats-not-working-without-earliest"&gt;http://splunk-base.splunk.com/answers/42084/latest-function-in-stats-not-working-without-earliest&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:13:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24502#M4520</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-11T15:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24503#M4521</link>
      <description>&lt;P&gt;Yep, that's exactly it.  Guess I should search more carefully before I post.  Thanks!&lt;/P&gt;

&lt;P&gt;My Splunk version is 4.3 build 115073, if that helps you.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:17:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24503#M4521</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2012-04-11T15:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24504#M4522</link>
      <description>&lt;P&gt;In the mean time, use;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|metadata type=hosts index=foo | eval Last_seen = strftime(lastTime, "%Y-%m-%d %H:%M:%S")| fields + host Last_seen 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: Much faster than what I just posted. Deleted that. Sorry. &lt;BR /&gt;
EDIT AGAIN: cut-n-paste silliness. Corrected now.&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24504#M4522</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-11T15:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24505#M4523</link>
      <description>&lt;P&gt;Works nicely.  Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2012 17:07:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24505#M4523</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2012-04-11T17:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24506#M4524</link>
      <description>&lt;P&gt;Please see &lt;A href="http://splunk-base.splunk.com/answers/42084/latest-function-in-stats-not-working-without-earliest/45293"&gt;http://splunk-base.splunk.com/answers/42084/latest-function-in-stats-not-working-without-earliest/45293&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2012 17:14:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24506#M4524</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2012-04-11T17:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24507#M4525</link>
      <description>&lt;P&gt;I don't understand the workaround. Where are we supposed to get lastTime? isn't that the whole point with using the latest function? I am using version 5.0.1 and still experiencing this issue.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2013 20:45:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24507#M4525</guid>
      <dc:creator>srowe</dc:creator>
      <dc:date>2013-03-26T20:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: stats latest not returning a value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24508#M4526</link>
      <description>&lt;P&gt;The workaround is for this particular question: "At what time did we receive the last message for each host?"&lt;/P&gt;

&lt;P&gt;This can be answered by querying the metdata instead of the events themselves. Pretty much the same by which Splunk instantly 'knows' and presents the times for the oldest/newest event in the landing page for the Search app and for each index in Manager -&amp;gt; Indexes. &lt;/P&gt;

&lt;P&gt;The lastTime is returned (in epoch format) by the &lt;CODE&gt;|metadata&lt;/CODE&gt; search command. To present it in a nicer fashion it is then &lt;CODE&gt;eval&lt;/CODE&gt;:ed with &lt;CODE&gt;strftime&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Have you tried it?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2013 20:54:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-latest-not-returning-a-value/m-p/24508#M4526</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-03-26T20:54:55Z</dc:date>
    </item>
  </channel>
</rss>

