<?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: help on a max or a latest function which doent works in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380622#M170463</link>
    <description>&lt;P&gt;You would want latest too because max over a large time period may not be what you're expecting&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jul 2019 13:17:36 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2019-07-08T13:17:36Z</dc:date>
    <item>
      <title>help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380617#M170458</link>
      <description>&lt;P&gt;hello&lt;/P&gt;

&lt;P&gt;The max function in this search doesnt works. Idem with latest!&lt;BR /&gt;
Its not the latest or max event taked into account but the min or the oldest!&lt;BR /&gt;
what is the problem please??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x sourcetype=wireless_client_val 
| eval LAST_SEEN=strptime(LAST_SEEN, "%Y-%m-%d %H:%M:%S.%1N") 
| eval diff_seconds=now()-LAST_SEEN
| where diff_seconds&amp;gt;(60*60*24*5) 
| search 
    [ inputlookup host.csv 
    | table host 
    | rename host as USERNAME] 
| lookup lookup_cmdb_fo_all.csv HOSTNAME as USERNAME output SITE 
| search SITE="*" 
| eval LAST_SEEN_DAYS=round((now()-LAST_SEEN)/60/60/24,1) 
| stats values(SITE) as SITE, max(LAST_SEEN_DAYS) as Days_of_last_seen by USERNAME 
| sort -Days_of_last_seen
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2019 11:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380617#M170458</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-07-08T11:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380618#M170459</link>
      <description>&lt;P&gt;Can you perhaps share some data going into the  stats command (a table with a number of rows with at least these fields: _time, LAST_SEEN_DAYS,username) and data coming out and how that is different from what you expect?&lt;/P&gt;

&lt;P&gt;I cannot imagine &lt;CODE&gt;max(LAST_SEEN_DAYS)&lt;/CODE&gt; returning the events with &lt;CODE&gt;min(LAST_SEEN_DAYS)&lt;/CODE&gt; instead. Same for &lt;CODE&gt;latest()&lt;/CODE&gt;, unless you have been messing with the _time field (which doesn't seem to be the case from the search you are sharing), that should also behave as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380618#M170459</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T01:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380619#M170460</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
What I want to say is that the events returned by my stats command correspond to the difference between now() and the oldest LAST_SEEN events instead the latest&lt;BR /&gt;
Example:&lt;BR /&gt;
For example, for the first event returned by the search, the latest _time field value is 08/0719 13:29 and the oldest _time field value is 01/07/19 17:59&lt;BR /&gt;
So normally,LAST_SEEN_DAYS for this USERNAME hast to be now() - 08/0719 13:29 so 0,1 days&lt;BR /&gt;
But instead this I have 7 days so it means now() - 01/07/19 17:59&lt;BR /&gt;
Very strange&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:15:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380619#M170460</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-30T01:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380620#M170461</link>
      <description>&lt;P&gt;If you replace &lt;CODE&gt;max(LAST_SEEN_DAYS)&lt;/CODE&gt; with &lt;CODE&gt;values(LAST_SEEN_DAYS)&lt;/CODE&gt; you'll see all the LAST_SEEN_DAYS values for each host.  You may see something like &lt;CODE&gt;1,7&lt;/CODE&gt;.  The MAX of those values is 7, which is what you are getting.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:15:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380620#M170461</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-09-30T01:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380621#M170462</link>
      <description>&lt;P&gt;yes but like I said previously if my last or my max events _time is 08/0719 13:29 , I need to have 0,1 days displayed instead 7 days&lt;BR /&gt;
my issue is on the LAST_SEEN_DAYS calculation&lt;BR /&gt;
and when I use max or latest, normally it the last event that is taken into account&lt;BR /&gt;
and for me no&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:15:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380621#M170462</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-30T01:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380622#M170463</link>
      <description>&lt;P&gt;You would want latest too because max over a large time period may not be what you're expecting&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:17:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380622#M170463</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-07-08T13:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380623#M170464</link>
      <description>&lt;P&gt;I don't completely follow, but it sounds like you may want to do a &lt;CODE&gt;| stats values(SITE) as SITE latest(LAST_SEEN) as LAST_SEEN by USERNAME&lt;/CODE&gt; before doing any of the calculations instead of doing that stats at the end.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380623#M170464</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-07-08T13:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380624#M170465</link>
      <description>&lt;P&gt;Sorry I dont understand&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:34:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380624#M170465</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-07-08T13:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380625#M170466</link>
      <description>&lt;P&gt;Something like this (I also moved the subsearch into the main search instead of a separate search command):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x sourcetype=wireless_client_val [ inputlookup host.csv | table host | rename host as USERNAME] 
 | lookup lookup_cmdb_fo_all.csv HOSTNAME as USERNAME output SITE 
 | search SITE="*" 
 | eval LAST_SEEN=strptime(LAST_SEEN, "%Y-%m-%d %H:%M:%S.%1N") 
 | stats values(SITE) as SITE, latest(LAST_SEEN) as LAST_SEEN by USERNAME 
 | eval diff_seconds=now()-LAST_SEEN
 | where diff_seconds&amp;gt;(60*60*24*5) 
 | eval LAST_SEEN_DAYS=round((now()-LAST_SEEN)/60/60/24,1) 
 | sort -Days_of_last_seen
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:55:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380625#M170466</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-07-08T13:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: help on a max or a latest function which doent works</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380626#M170467</link>
      <description>&lt;P&gt;Oh now it seems to be correct!&lt;BR /&gt;
I just dont clearly well why we have to put the eval after the stats&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 15:16:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-a-max-or-a-latest-function-which-doent-works/m-p/380626#M170467</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-07-08T15:16:31Z</dc:date>
    </item>
  </channel>
</rss>

