Splunk Search

How do you calculate the average for a chart count over table?

cfstoica
New Member

How do you add another column that contains averages based on previous columns after "chart count over Level by Month"?

Level Month1 Month2 Month3 Average
1 2 3 4 3
2 4 5 6 5
3 4 6 8 6
....

0 Karma

renjith_nair
Legend

@cfstoica,

If the number of months are dynamic, then give this a try,

chart count over Level by Month|addtotals|eval Total=Total-Level|eval colcount=-3
|foreach * [eval colcount=colcount+1]|eval Average=Total/colcount|fields - Total,colcount
Happy Splunking!
0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

Is it always the same columns? You could do something like the following if so:

... | eval avgbylevel=(Month1 + Month2 + Month3)/3 | table Level Month1 Month2 Month3 avgbylevel
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 ...