<?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 express multiple average windows in a table form? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627052#M217926</link>
    <description>&lt;P&gt;First, I think you mean&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;| streamstats time_window=5m avg(myval) as five_min_val by host
| streamstats time_window=15m avg(myval) as fifteen_min_val by host&lt;/LI-CODE&gt;&lt;P&gt;Secondly, you need to illustrate what the actual output from your code and illustrate the desired output, explain any difference that is not obvious to volunteers who are unfamiliar with your original data.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jan 2023 10:09:43 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-01-13T10:09:43Z</dc:date>
    <item>
      <title>How to express multiple average windows in a table form?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/626917#M217874</link>
      <description>&lt;P&gt;I am having trouble expressing multiple average windows in a table form.&amp;nbsp; My table shows the same values for myval, five_min_val, fifteen_min_val for each host.&amp;nbsp; I can get some of what I want from timechart and trellis layout on each of the aggregations for a single host, but I really would like to look at the data across hundreds of hosts, where the value is above some threshold over 15 minutes.&amp;nbsp; I tried trendline and sma5, sma15 to represent the 5 min and 15 min simple moving averages with similar effect.&lt;/P&gt;
&lt;P&gt;Please enlighten me?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;&amp;lt;base search&amp;gt;
| fields _time host myval
| bins span=1m _time
| streamstats window=5 avg(myval) as five_min_val by host
| streamstats window=15 avg(myval) as fifteen_min_val by host
| stats latest(myval) as myval latest(five_min_val) as five_min_val latest(fifteen_min_val) as fifteen_min_val by host
| table host myval five_min_val fifteen_min_val&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 20:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/626917#M217874</guid>
      <dc:creator>peiffer</dc:creator>
      <dc:date>2023-01-12T20:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to express multiple average windows in a table form?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627052#M217926</link>
      <description>&lt;P&gt;First, I think you mean&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;| streamstats time_window=5m avg(myval) as five_min_val by host
| streamstats time_window=15m avg(myval) as fifteen_min_val by host&lt;/LI-CODE&gt;&lt;P&gt;Secondly, you need to illustrate what the actual output from your code and illustrate the desired output, explain any difference that is not obvious to volunteers who are unfamiliar with your original data.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 10:09:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627052#M217926</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-13T10:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to express multiple average windows in a table form?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627295#M217983</link>
      <description>&lt;P&gt;You were absolutely right on the first point. I did drop the minute modifier on the time_window after contorting my example multiple times and not making any progress and as a result made typos.&lt;BR /&gt;&lt;BR /&gt;On the second point, below are the example searches and the outputs. Note, I did change the stats to use aggregator avg() instead of latest() from the streamstats. Now changing the aggregator was actually what was needed, solving my own problem, I think. I believe the issue was my use of latest load, 5min load, 15min load was the cause of the problem.&amp;nbsp; Please validate my thinking.&lt;BR /&gt;&lt;BR /&gt;How would getting the below example searches and output to compare or contrast help you enlighten me?&lt;/P&gt;&lt;PRE&gt;&amp;lt;&lt;SPAN&gt;mysearch&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;| &lt;SPAN&gt;bin span&lt;/SPAN&gt;=&lt;SPAN&gt;1m &lt;/SPAN&gt;_&lt;SPAN&gt;time&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;eval load &lt;/SPAN&gt;= &lt;SPAN&gt;round&lt;/SPAN&gt;(&lt;SPAN&gt;PercentUserTime &lt;/SPAN&gt;+ &lt;SPAN&gt;PercentSystemTime&lt;/SPAN&gt;, &lt;SPAN&gt;1&lt;/SPAN&gt;)&lt;BR /&gt;| &lt;SPAN&gt;eval host&lt;/SPAN&gt;="&lt;SPAN&gt;foo&lt;/SPAN&gt;"&lt;BR /&gt;| &lt;SPAN&gt;streamstats time_window&lt;/SPAN&gt;=&lt;SPAN&gt;5m avg&lt;/SPAN&gt;(&lt;SPAN&gt;load&lt;/SPAN&gt;) &lt;SPAN&gt;as five_min_load by host&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;streamstats time_window&lt;/SPAN&gt;=&lt;SPAN&gt;15m avg&lt;/SPAN&gt;(&lt;SPAN&gt;load&lt;/SPAN&gt;) &lt;SPAN&gt;as fifteen_min_load by host&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;timechart span&lt;/SPAN&gt;=&lt;SPAN&gt;1m partial&lt;/SPAN&gt;=&lt;SPAN&gt;false avg&lt;/SPAN&gt;(&lt;SPAN&gt;load&lt;/SPAN&gt;) &lt;SPAN&gt;as load avg&lt;/SPAN&gt;(&lt;SPAN&gt;five_min_load&lt;/SPAN&gt;) &lt;SPAN&gt;as five_min_load avg&lt;/SPAN&gt;(&lt;SPAN&gt;fifteen_min_load&lt;/SPAN&gt;) &lt;SPAN&gt;as fifteen_min_load by host&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;_&lt;SPAN&gt;time  &lt;/SPAN&gt;fifteen_min_load: foo  five_min_load: foo load: foo&lt;BR /&gt;&lt;SPAN&gt;2023-01-16 &lt;/SPAN&gt;16:46:00    5.3    5.1    5.5&lt;BR /&gt;&lt;SPAN&gt;2023-01-16 &lt;/SPAN&gt;16:47:00    5.3    5.5    17.2&lt;/PRE&gt;&lt;PRE&gt;&amp;lt;&lt;SPAN&gt;mysearch&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;| &lt;SPAN&gt;bin span&lt;/SPAN&gt;=&lt;SPAN&gt;1m &lt;/SPAN&gt;_&lt;SPAN&gt;time&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;eval load &lt;/SPAN&gt;= &lt;SPAN&gt;round&lt;/SPAN&gt;(&lt;SPAN&gt;PercentUserTime &lt;/SPAN&gt;+ &lt;SPAN&gt;PercentSystemTime&lt;/SPAN&gt;, &lt;SPAN&gt;1&lt;/SPAN&gt;)&lt;BR /&gt;| &lt;SPAN&gt;eval host&lt;/SPAN&gt;="&lt;SPAN&gt;foo&lt;/SPAN&gt;"&lt;BR /&gt;| &lt;SPAN&gt;streamstats time_window&lt;/SPAN&gt;=&lt;SPAN&gt;5m avg&lt;/SPAN&gt;(&lt;SPAN&gt;load&lt;/SPAN&gt;) &lt;SPAN&gt;as five_min_load by host&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;streamstats time_window&lt;/SPAN&gt;=&lt;SPAN&gt;15m avg&lt;/SPAN&gt;(&lt;SPAN&gt;load&lt;/SPAN&gt;) &lt;SPAN&gt;as fifteen_min_load by host&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;stats latest&lt;/SPAN&gt;(_&lt;SPAN&gt;time&lt;/SPAN&gt;) &lt;SPAN&gt;as &lt;/SPAN&gt;_&lt;SPAN&gt;time avg&lt;/SPAN&gt;(&lt;SPAN&gt;load&lt;/SPAN&gt;) &lt;SPAN&gt;as load avg&lt;/SPAN&gt;(&lt;SPAN&gt;five_min_load&lt;/SPAN&gt;) &lt;SPAN&gt;as five_min_load avg&lt;/SPAN&gt;(&lt;SPAN&gt;fifteen_min_load&lt;/SPAN&gt;) &lt;SPAN&gt;as fifteen_min_load by host&lt;BR /&gt;&lt;/SPAN&gt;| &lt;SPAN&gt;table &lt;/SPAN&gt;_&lt;SPAN&gt;time host load five_min_load fifteen_min_load&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;_&lt;SPAN&gt;time  host   load   five_min_load  fifteen_min_load&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;2023-01-16 &lt;/SPAN&gt;16:55:00    foo    4.9    5.5    5.4&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 23:41:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627295#M217983</guid>
      <dc:creator>peiffer</dc:creator>
      <dc:date>2023-01-16T23:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to express multiple average windows in a table form?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627304#M217985</link>
      <description>&lt;P&gt;Semantically, if you use latest in streamstats, Splunk should return the latest value of that field in the past 5 minutes, 15 minutes, 1 hour, or 15 hours, whichever the time_window is. &amp;nbsp;You would not expect the latest value to be different just because time_window is different. &amp;nbsp;I think this concludes the original question about why you saw identical values with very different time_window.&lt;/P&gt;&lt;P&gt;I am not sure what the other question is. &amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Timechart" target="_blank" rel="noopener"&gt;Timechart&lt;/A&gt; and &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats" target="_blank" rel="noopener"&gt;stats&lt;/A&gt; perform different operations, therefore they will give different results. &amp;nbsp;This is not related to how you use them. (The documents include some useful examples.) &amp;nbsp;If you are wondering why the groupby field (host) got represented in column names in timechart while they appear as a separate column in stats, you can try to redesign timechart (whose purpose is to plot values on time scale) and see if you can come up with a better representation.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 06:40:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627304#M217985</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-17T06:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to express multiple average windows in a table form?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627305#M217986</link>
      <description>&lt;P&gt;Looks like you misunderstand the use of bin.&lt;/P&gt;&lt;P&gt;Using bin with _time+stats is only useful if you stats by _time also&lt;/P&gt;&lt;P&gt;In your second search if you want 1 minute latest intervals by time you must also split by time, otherwise the bin command is redundant&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats latest(_time) as _time avg(load) as load avg(five_min_load) as five_min_load avg(fifteen_min_load) as fifteen_min_load by _time host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 06:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-express-multiple-average-windows-in-a-table-form/m-p/627305#M217986</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-01-17T06:51:07Z</dc:date>
    </item>
  </channel>
</rss>

