<?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: How to use the per_second function with streamstats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141627#M39255</link>
    <description>&lt;P&gt;I think that something like this could help him&lt;BR /&gt;
Please martin_mueller could you help to verify in your side ?&lt;BR /&gt;
index="_introspection" | timechart per_second(data.localTime) as X| streamstats current=t global=f window=2 range(X) as X1&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 19:28:05 GMT</pubDate>
    <dc:creator>chimell</dc:creator>
    <dc:date>2020-09-28T19:28:05Z</dc:date>
    <item>
      <title>How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141621#M39249</link>
      <description>&lt;P&gt;I'm trying to use &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/Streamstats"&gt;streamstats&lt;/A&gt; on Splunk 6.2.2.255606 and the per_second stats-function is killing me. I'm trying to find the delta per second of an incrementing counter. Here's an example using some data from the introspection log.&lt;/P&gt;

&lt;P&gt;This one works and gives me the delta between the two events (I need it per second):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_introspection"| streamstats current=t global=f window=2 range(data.localTime) as X
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but when I try the same thing to get the per_second value Splunk throws an error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_introspection"| streamstats current=t global=f window=2 per_second(data.localTime) as X_per_second
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Error in 'streamstats' command: The argument 'per_second(data.localTime)' is invalid.&lt;/P&gt;

&lt;P&gt;A work around is to get the time delta and calculate the per_second value using an eval:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_introspection" | streamstats current=t global=f window=2 range(data.localTime) as X_range range(_time) as time_delta  | eval X_per_second=X_range/time_delta
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but that makes my searches messy and I would really like to use the per_second stats-function if I can.&lt;/P&gt;

&lt;P&gt;Has anyone successfully got the streamstats per_second function working? Am I missing something obvious here?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2015 01:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141621#M39249</guid>
      <dc:creator>Skippy</dc:creator>
      <dc:date>2015-04-12T01:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141622#M39250</link>
      <description>&lt;P&gt;&lt;CODE&gt;per_second()&lt;/CODE&gt; is only applicable to &lt;CODE&gt;timechart&lt;/CODE&gt;, see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/CommonStatsFunctions&lt;/A&gt; for reference.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2015 06:29:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141622#M39250</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-04-12T06:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141623#M39251</link>
      <description>&lt;P&gt;Hi Skippy&lt;BR /&gt;
As martin_mueller told  ,  per_second() function is easily applicable to timechart command .Therefore , you can use a subsearch use timechart and per_second() function before use streamstats command&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141623#M39251</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2020-09-28T19:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141624#M39252</link>
      <description>&lt;P&gt;How would you replace &lt;CODE&gt;streamstats&lt;/CODE&gt; with &lt;CODE&gt;timechart&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2015 11:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141624#M39252</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-04-13T11:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141625#M39253</link>
      <description>&lt;P&gt;Hi martin_mueller&lt;BR /&gt;
I say that you can use timechart  and streamstats in the same request , you make sure that timechart command come before streamstats : look at an example &lt;BR /&gt;
    ... | timechart span=1h sum(value) as total by category | streamstats&lt;BR /&gt;
    global=f sum(total) as accu_total&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141625#M39253</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2020-09-28T19:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141626#M39254</link>
      <description>&lt;P&gt;How can that approach be applied to the question at hand, calculating "per_second(data.localTime)"?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2015 14:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141626#M39254</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-04-13T14:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the per_second function with streamstats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141627#M39255</link>
      <description>&lt;P&gt;I think that something like this could help him&lt;BR /&gt;
Please martin_mueller could you help to verify in your side ?&lt;BR /&gt;
index="_introspection" | timechart per_second(data.localTime) as X| streamstats current=t global=f window=2 range(X) as X1&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:28:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-per-second-function-with-streamstats/m-p/141627#M39255</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2020-09-28T19:28:05Z</dc:date>
    </item>
  </channel>
</rss>

