<?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 do you use the streamstats command after tstats and stats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388191#M113195</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats avg(elapsed) as avgElapsed where host="A"  index="X" sourcetype="Y" ID="Z" by _time, host,ID span=1week 
 | eval myval = host."-".ID 
 | stats sum(count) as count latest(avgElapsed) as avgElapsed by myval _time
 | streamstats current=f window=1 latest(avgElapsed) as prev_elapsed by myval
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Nov 2018 16:56:19 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-11-20T16:56:19Z</dc:date>
    <item>
      <title>How do you use the streamstats command after tstats and stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388189#M113193</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thanks upfront for your time. I need to aggregate some information with the tstats command and make a weekly comparative analysis. &lt;BR /&gt;
The search I created is working if i pick parameters, however, it doesn't if I don't give any parameters due to nature of |streamstats. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats avg(elapsed) as avgElapsed where host="A"  index="X" sourcetype="Y" ID="Z" by _time, host,ID span=1week 
| eval myval = host."-".ID 
| stats sum(count) as count latest(avgElapsed) as avgElapsed by _time,myval 
| streamstats current=f window=1 latest(avgElapsed) as prev_elapsed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Logically, I would expect adding "by" clause to the streamstats command should get me what I need. However, it is not returning results for previous weeks when I do that. It only works on a row by row basis, which points to another ID or host in the data sometimes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    | streamstats current=f window=1 latest(avgElapsed) as prev_elapsed by myval
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help me out. Kind regards&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 17:21:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388189#M113193</guid>
      <dc:creator>akocak</dc:creator>
      <dc:date>2018-11-19T17:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use the streamstats command after tstats and stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388190#M113194</link>
      <description>&lt;P&gt;@akocak,&lt;/P&gt;

&lt;P&gt;Sorry if mistaken but if you are trying to bring value from previous row to current row, then try using &lt;CODE&gt;last&lt;/CODE&gt; instead of &lt;CODE&gt;latest&lt;/CODE&gt; in streamstats.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 16:44:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388190#M113194</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-11-20T16:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use the streamstats command after tstats and stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388191#M113195</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats avg(elapsed) as avgElapsed where host="A"  index="X" sourcetype="Y" ID="Z" by _time, host,ID span=1week 
 | eval myval = host."-".ID 
 | stats sum(count) as count latest(avgElapsed) as avgElapsed by myval _time
 | streamstats current=f window=1 latest(avgElapsed) as prev_elapsed by myval
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 16:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-streamstats-command-after-tstats-and-stats/m-p/388191#M113195</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-11-20T16:56:19Z</dc:date>
    </item>
  </channel>
</rss>

