Splunk Search

What is the difference between sma and avg?

simona2121
Path Finder

I want to know the exact difference between sma and avg. Also, can someone pls provide detailed description of trendline?

Tags (2)
1 Solution

jkat54
SplunkTrust
SplunkTrust

index=_internal | timechart count | trendline sma5(count)

The number after sma is the number of buckets you want to average over.

So sma5(count) averages the last 5 occurrences of count, whereas avg(count) would only be the average number of count in that time bucket.

Say you have a field called sales, and these are your events:

8/8 - sales=100
8/8 - sales=50
8/8 - sales=100
8/8 - sales=50
8/9 - sales=200
8/9 - sales=100
8/9 - sales=200
8/9 - sales=100

The avg(sales) on 8/8 is 75, the avg(sales) on 8/9 is 150, the sma2(sales) is 112.5 on 8/9 but it wont even compute for 8/8 because you only have 1 day of trailing data with sales and you wanted sma2. AND this is assuming you put your data in buckets which equal 1 day of time each... if you add timestamps for hours, timechart would then change to different bucket sizes. You can force bucket sizes with the bin or bucket commands.

https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Trendline
http://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Bin
bucket is alias of bin

View solution in original post

jkat54
SplunkTrust
SplunkTrust

index=_internal | timechart count | trendline sma5(count)

The number after sma is the number of buckets you want to average over.

So sma5(count) averages the last 5 occurrences of count, whereas avg(count) would only be the average number of count in that time bucket.

Say you have a field called sales, and these are your events:

8/8 - sales=100
8/8 - sales=50
8/8 - sales=100
8/8 - sales=50
8/9 - sales=200
8/9 - sales=100
8/9 - sales=200
8/9 - sales=100

The avg(sales) on 8/8 is 75, the avg(sales) on 8/9 is 150, the sma2(sales) is 112.5 on 8/9 but it wont even compute for 8/8 because you only have 1 day of trailing data with sales and you wanted sma2. AND this is assuming you put your data in buckets which equal 1 day of time each... if you add timestamps for hours, timechart would then change to different bucket sizes. You can force bucket sizes with the bin or bucket commands.

https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Trendline
http://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Bin
bucket is alias of bin

jkat54
SplunkTrust
SplunkTrust

The simple moving average (SMA) is the most basic of the moving averages used for stock/futures trading usually. The simple moving average formula is calculated by taking the average closing price of a stock over the last "x" periods. (x@noon+x@1pm+x@2pm)/3

Average (AVG) is the sum of all the parts divided by the number of the parts (x+y+z)/3

0 Karma

somesoni2
Revered Legend

The sma is available in trendline. Here is documentation on Trendline

https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Trendline

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...