Splunk Search

Daily averages in usage over 7 days or similar...

antb
Path Finder
index=_internal source="*license_usage.log*" type=Usage idx IN (index1,index2,index3, index4,etcindex) 
| eval yearmonthday=strftime(_time, "%m-%d-%Y") 
| stats sum(eval(round(b/1024/1024/1024,4))) AS volume_gb by idx yearmonthday 
| chart sum(volume_gb) over idx by yearmonthday | addtotals col=true fieldname="Total GB" labelfield=idx

The above works great showing me my daily index usage (have it set for the previous 7 full days)

But I would much rather print the row total as averages instead of totals while keeping the column totals. Any idea? Additionally, how can I sort this by average size descending but keeping the total row at the bottom?

Thank you

0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

index=_internal source="*license_usage.log*" type=Usage idx IN (index1,index2,index3, index4,etcindex) 
 | eval yearmonthday=strftime(_time, "%m-%d-%Y") 
 | stats sum(eval(round(b/1024/1024/1024,4))) AS volume_gb by idx yearmonthday 
 | appendpipe [| stats avg(volume_gb) as volume_gb by idx | eval yearmonthday="ZZZZ" ]
 | chart sum(volume_gb) over idx by yearmonthday 
 | sort -ZZZZ | rename "ZZZZ" as "Average GB"
 | addcoltotals labelfield=idx

View solution in original post

somesoni2
Revered Legend

Give this a try

index=_internal source="*license_usage.log*" type=Usage idx IN (index1,index2,index3, index4,etcindex) 
 | eval yearmonthday=strftime(_time, "%m-%d-%Y") 
 | stats sum(eval(round(b/1024/1024/1024,4))) AS volume_gb by idx yearmonthday 
 | appendpipe [| stats avg(volume_gb) as volume_gb by idx | eval yearmonthday="ZZZZ" ]
 | chart sum(volume_gb) over idx by yearmonthday 
 | sort -ZZZZ | rename "ZZZZ" as "Average GB"
 | addcoltotals labelfield=idx

VatsalJagani
SplunkTrust
SplunkTrust

Hello @antb,

Please add below query at the end of your current search instead of using addtotals command.

| appendpipe [| stats avg(*) as * | eval idx="Avg usage"]

Hope this helps!!!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...