Splunk Search

total average number rather than average by field

andrwbn
Engager

I have the query set up to find the average duration per country. How would I get the query to find the total average duration of all the countries together?

0 Karma
1 Solution

hunters_splunk
Splunk Employee
Splunk Employee

Hi andrwbn,

Either one of the following can help you get the total average duration of all countries:

  • Remove "by country" in our query
    Change:

    ... | stats avg(duration) by country

    To:

    ... | stats avg(duration)

  • Use the addcoltotals command to view both by-country averages and total averages at the same time

    ... | stats avg(duration) by country | addcoltotals
    Hope this helps. Thanks!
    Hunter

View solution in original post

0 Karma

hunters_splunk
Splunk Employee
Splunk Employee

Hi andrwbn,

Either one of the following can help you get the total average duration of all countries:

  • Remove "by country" in our query
    Change:

    ... | stats avg(duration) by country

    To:

    ... | stats avg(duration)

  • Use the addcoltotals command to view both by-country averages and total averages at the same time

    ... | stats avg(duration) by country | addcoltotals
    Hope this helps. Thanks!
    Hunter

0 Karma

rjthibod
Champion

The community can best help you if you share the query or at least part of it. Please copy and paste what you can from the actual query.

0 Karma

skoelpin
SplunkTrust
SplunkTrust

Without seeing your query, this is hard to say. But I'm betting you're using the BY clause to sort the average by country. Remove the BY COUNTRY to get the total average

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!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...