Splunk Search

Addtotals does not include 'Other'

jvamplew
New Member

When I add a limit to a timechart to reduce the number of visible series (improve dashboard performance) it changes the value of Total when using addtotals.

Example:

 

| timechart span=1s avg(host_usage) by host useother=true
| addtotals

 

The below gives me a lower overall total than the above:

 

| timechart span=1s avg(host_usage) by host limit=5 useother=true
| addtotals

 

I thought Other was supposed to be the total of all other values not explicitly displayed?

Labels (1)
Tags (3)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

You will need to carefully calibrate your result before drawing conclusions.  In other words, compare apples to apples.  Try this exercise: run the following two within the same calendar hour.  First

 

<somesearch> earliest=-1h@h latest=-0h@h
| timechart span=1s avg(host_usage) by host useother=true
| addtotals
| table _time Total *

 

Then this

 

<somesearch> earliest=-1h@h latest=-0h@h
| timechart span=1s avg(host_usage) by host useother=true limit=5
| addtotals
| table _time Total *

 

What the earliest and latest do in this exercise is to eliminate any bucket error. (I am curious what use case could warrant timechart with span 1s.)  The table command is so you can easily compare Total in each row.

When I test this method, Total does not change when I set limit.  Here is the test set:

 

index=_audit earliest=-1d@d latest=-0d@d
| timechart span=4h count by action useother=true
| addtotals
| table _time Total *

 

_timeTotaladddeleteexpired_session_tokenlogin_attemptquotaread_session_tokensearchupdatevalidate_token
2024-07-07 21:00159200140178730787
2024-07-08 01:00453001318199330199
2024-07-08 05:00212003189510095
2024-07-08 09:00196500928964144964
2024-07-08 13:006508002221032163473217
2024-07-08 17:0070591100035191633519
2024-07-08 21:0049660000024781002478

 

index=_audit earliest=-1d@d latest=-0d@d
| timechart span=4h count by action useother=true limit=3
| addtotals
| table _time Total *

 

_timeTotalOTHERread_session_tokensearchvalidate_token
2024-07-07 21:001592157873787
2024-07-08 01:004532219933199
2024-07-08 05:0021212951095
2024-07-08 09:0019652396414964
2024-07-08 13:006508413216343217
2024-07-08 17:00705953519163519
2024-07-08 21:00496602478102478

As you can see, the Total column in the two output are exactly identical.

Suggestion: If your event density is extremely high (given that you are using 1s time bucket), you can use snap-to anchor ("@", see Specify a snap to time unit) to avoid indeterministic time bucket

 

<somesearch>
| timechart span=1s@s avg(host_usage) by host useother=true
| addtotals
<somesearch>
| timechart span=1s@s avg(host_usage) by host useother=true limit=5
| addtotals

 

 

0 Karma

jvamplew
New Member

Thanks Giuseppe.

Unfortunately that is the problem, I actually have 30 values. I want to display the total for all, but don't necessarily want to chart them all, as this many series over a number of charts tends to slow down the dashboard. I was hoping that by using Other, it would sum the other values into that column, thereby allowing me to display an accurate total while not displaying all the values. 

Is there a way to do this? I'm thinking it may only work by appending a subsearch for the total and overlaying it on the original chart, but I was trying to avoid adding another search for every panel that displays this data. 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jvamplew ,

I'm not sure, but it should run:

<your_search>
| bin span=1s -time
| stats avg(host_usage) by host useother=true
| addtotals
| timechart span=1s avg(host_usage) by host limit=7 useother=true

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jvamplew,

if you use limit=5, you'll have 5 results, so you don't need to use useother.

In this way addtotals summarize only the results of the search, in other words, only the first 5 values.

Ciao.

Giuseppe

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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...