<?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 get stdev and avg from a multi column timechart for eventflow trends in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stdev-and-avg-from-a-multi-column-timechart-for/m-p/496091#M138252</link>
    <description>&lt;P&gt;I should also mention the ultimate goal is to have the data look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        avg     current     stdev   z
index1  1       2           3           3
index2  2       3           3           4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Sep 2019 17:38:11 GMT</pubDate>
    <dc:creator>wlcv</dc:creator>
    <dc:date>2019-09-30T17:38:11Z</dc:date>
    <item>
      <title>How to get stdev and avg from a multi column timechart for eventflow trends</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stdev-and-avg-from-a-multi-column-timechart-for/m-p/496090#M138251</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I want to compare my event flow rate from the benchmark (last 21 - last 7 days [14 days in total] to the last 7 days to determine if there are any abnormal activities or to determine how my flow is trending. My process is to take the averages of the baseline and current along with the standard deviation to determine the zscore and work from that.&lt;/P&gt;

&lt;P&gt;The problem s that the search takes  ~290 seconds and I'm hoping to see if there are any efficiencies that can be performed to make this work better. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=* earliest=-21d@d latest=-7d@d by _time index span=1h summariesonly=t 
| timechart span=1h sum(count) as count by index useother=f 
| fillnull value=0 
| stats avg(*) as * 
| transpose 0 
| rename "row 1" as avg column as index 
| appendcols 
    [| tstats count where index=* earliest=-21d@d latest=-7d@d by _time index span=1h summariesonly=t 
    | timechart span=1h sum(count) as count by index useother=f 
    | fillnull value=0 
    | stats stdev(*) as * 
    | transpose 0 
    | rename "row 1" as stdev column as index ] 
| appendcols 
    [| tstats count where index=* earliest=-7d@d latest=@h by _time index span=1h summariesonly=t 
    | timechart span=1h sum(count) as count by index useother=f 
    | fillnull value=0 
    | stats avg(*) as * 
    | transpose 0 
    | rename "row 1" as current column as index ] 
| eval z = (avg - current)/stdev
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Initially, instead of appendcols I used join but it seems appendcols is slightly faster. Part of the issue is that I can't get the stdev and avg in a single table easily (examples of my issues below).&lt;/P&gt;

&lt;P&gt;example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=* earliest=-1d@d latest=@d by _time index span=1h summariesonly=t 
| timechart span=1h sum(count) as count by index useother=f
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;_time                index1  index2  index3  index4  index5  index6  index7  index8  index9  inedex10&lt;BR /&gt;
2019-09-29 00:00    114929  109862  5447236 598915  101984  93383   1134374 3218677 135260  271187&lt;BR /&gt;
2019-09-29 01:00    113735  94834   8043144 500234  101288  93374   1683179 3212936 268802  277495&lt;BR /&gt;
2019-09-29 02:00    114069  99818   9472714 460066  99908   93260   1632044 3241514 857129  268001&lt;BR /&gt;
...&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;If I use the following search, I can't seem to get the stdev and avg sorted by the index. Using &lt;CODE&gt;stats avg(*) as avg_* stdev(*) by stdev_* by index&lt;/CODE&gt; gets me no results... And the following doesn't help with getting the avg/stdev by the index respectively so I had to resort to using the &lt;CODE&gt;transpose 0&lt;/CODE&gt; lines and joining the different searches together &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=* earliest=-1d@d latest=@d by _time index span=1h summariesonly=t 
| timechart span=1h sum(count) as count by index useother=f 
| fillnull value=0 
| stats avg(*) as avg_* stdev(*) as stdev_*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;avg_index1            avg_index2  avg_index3  ...     stdev_index1        stdev_index2    stdev_index3        ...&lt;BR /&gt;
79202.82857857      72468.4     7022379.3   ...     20705.25571     74106.285571    63430.8         ...&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Please let me know what else I can try to pretty this up. Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-stdev-and-avg-from-a-multi-column-timechart-for/m-p/496090#M138251</guid>
      <dc:creator>wlcv</dc:creator>
      <dc:date>2020-09-30T02:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get stdev and avg from a multi column timechart for eventflow trends</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stdev-and-avg-from-a-multi-column-timechart-for/m-p/496091#M138252</link>
      <description>&lt;P&gt;I should also mention the ultimate goal is to have the data look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        avg     current     stdev   z
index1  1       2           3           3
index2  2       3           3           4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2019 17:38:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-stdev-and-avg-from-a-multi-column-timechart-for/m-p/496091#M138252</guid>
      <dc:creator>wlcv</dc:creator>
      <dc:date>2019-09-30T17:38:11Z</dc:date>
    </item>
  </channel>
</rss>

