<?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: streamstats confusion in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170705#M48861</link>
    <description>&lt;P&gt;The second query is pretty close, however the lastFreePercent shows the updated figure &lt;EM&gt;before&lt;/EM&gt; the freePercent.  Despite this being sorted by server or _time.  Looking at &lt;A href="http://answers.splunk.com/answers/105733/streamstats-is-reversed"&gt;http://answers.splunk.com/answers/105733/streamstats-is-reversed&lt;/A&gt; to see if that helps me.  Thanks for all your help so far!&lt;/P&gt;</description>
    <pubDate>Fri, 23 May 2014 15:37:28 GMT</pubDate>
    <dc:creator>a_splunk_user</dc:creator>
    <dc:date>2014-05-23T15:37:28Z</dc:date>
    <item>
      <title>streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170697#M48853</link>
      <description>&lt;P&gt;Having some trouble with streamstats.  &lt;/P&gt;

&lt;P&gt;I need to be alerted, once, at the time when a logical drive becomes less that 10% available.  So, I have a script that writes a log file on a 5min interval, monitored by Splunk as sourcetype 'drivetracker'.  I need the query to one-time alert me when the freePercent falls below the 10% mark.  The source data looks correct.&lt;/P&gt;

&lt;P&gt;Problem is, the Splunk query is not giving me the lastFreePercent figure based on the freePercent figure from the previous log file?  &lt;/P&gt;

&lt;P&gt;Here is my query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="drivetracker"  devId="*" 
| streamstats current=f window=1 last(freePercent) as lastFreePercent
| where freePercent&amp;lt;10 AND lastFreePercent&amp;gt;9
| table _time, server, devId, freePercent, lastFreePercent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;and here are the results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;server  devId   totSpace    usedSpace   frSpace freePercent lastFreePercent
server1 C:  100 96.76   3.24    3   **98**
server1 E:  800 782.75  17.25   2   **76**
server1 F:  800 768.09  31.91   4   **24**
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Apologies for the poor formatting.  According to this, the three drives on server1 suddenly dropped a whole lot of space in under 5 minutes, which simply isn't the case.&lt;/P&gt;

&lt;P&gt;Any help is appreciated!&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2014 20:20:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170697#M48853</guid>
      <dc:creator>a_splunk_user</dc:creator>
      <dc:date>2014-05-19T20:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170698#M48854</link>
      <description>&lt;P&gt;Can you give this a try...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Updated answer:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="drivetracker"  devId="*"  | sort -_time
| streamstats current=f window=1 last(freePercent) as lastFreePercent by devId,server
| where freePercent&amp;lt;10 AND lastFreePercent&amp;gt;9
| table _time, server, devId, freePercent, lastFreePercent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Give this a try as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="drivetracker" devId="*" | sort server,devId,-_time | eval devId_server = devId . server | streamstats current=f window=2 last(freePercent) as lastFreePercent by devId_server | where freePercent&amp;lt;10 AND lastFreePercent&amp;gt;9 | table _time, server, devId, devId_server, freePercent, lastFreePercent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 May 2014 20:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170698#M48854</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-05-19T20:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170699#M48855</link>
      <description>&lt;P&gt;Thanks for the quick(!) response.  Unfortunately the problem persists.&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2014 20:40:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170699#M48855</guid>
      <dc:creator>a_splunk_user</dc:creator>
      <dc:date>2014-05-19T20:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170700#M48856</link>
      <description>&lt;P&gt;Can you validate if the source data looks correct by executing this..&lt;/P&gt;

&lt;P&gt;sourcetype="drivetracker" server="server1"  devId="C:" OR devId="E:" OR devId="F:"  | streamstats count by devId | where count &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;This should give you last 2 records for devId C:, E: and F: for server 1. Look at the value (if possible, provide it in the post) and see if really the 2nd last record says freepercent so high.&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2014 20:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170700#M48856</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-05-19T20:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170701#M48857</link>
      <description>&lt;P&gt;Also try the updated answer, just now seen that the grouping was missing from streamstats.&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2014 21:02:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170701#M48857</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-05-19T21:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170702#M48858</link>
      <description>&lt;P&gt;Interesting - when I ran the query you updated the lastFreePercent field was returned null values (returning zero records based on the filter).  Removing the lastFreePercent&amp;lt;x from the filter yielded results, with the current freePercent figure as accurate, it seems.&lt;/P&gt;

&lt;P&gt;The test showed that the source data appears to be correct.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2014 18:11:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170702#M48858</guid>
      <dc:creator>a_splunk_user</dc:creator>
      <dc:date>2014-05-20T18:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170703#M48859</link>
      <description>&lt;P&gt;By the way, this seems to be pretty close, when I aggregate the server &amp;amp; devId and streamstats by that, but only when I specify the a server &amp;amp; devId:&lt;/P&gt;

&lt;P&gt;sourcetype="drivetracker" devId="*" server="server1" devId="C:" | sort -_time | eval devId_server = devId . server | streamstats current=f window=2 last(freePercent) as lastFreePercent by devId_server | where freePercent&amp;lt;10 AND lastFreePercent&amp;gt;9 | table _time, server, devId, devId_server, freePercent, lastFreePercent&lt;/P&gt;

&lt;P&gt;Removing [server="server1" devId="C:"] causes a zero result set.  Weird!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:40:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170703#M48859</guid>
      <dc:creator>a_splunk_user</dc:creator>
      <dc:date>2020-09-28T16:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170704#M48860</link>
      <description>&lt;P&gt;Give the new answer a try...&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2014 19:40:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170704#M48860</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-05-20T19:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: streamstats confusion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170705#M48861</link>
      <description>&lt;P&gt;The second query is pretty close, however the lastFreePercent shows the updated figure &lt;EM&gt;before&lt;/EM&gt; the freePercent.  Despite this being sorted by server or _time.  Looking at &lt;A href="http://answers.splunk.com/answers/105733/streamstats-is-reversed"&gt;http://answers.splunk.com/answers/105733/streamstats-is-reversed&lt;/A&gt; to see if that helps me.  Thanks for all your help so far!&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2014 15:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/streamstats-confusion/m-p/170705#M48861</guid>
      <dc:creator>a_splunk_user</dc:creator>
      <dc:date>2014-05-23T15:37:28Z</dc:date>
    </item>
  </channel>
</rss>

