Splunk Search

Is there an easy way to do an "addaverages" instead of the addtotals function?

Cuyose
Builder

Is there an easy way to do an addaverages instead of addtotals?
I have the following and can't seem to use any provided solutions to get it to work.

   base search
    | bucket _time span=1m
    | stats count(eval(success="true")) as Success, count(eval(success="false")) as Failure, count as TotalAttempts by _time, proxy  
    | eval Error%=round(if(info="Success", Success, Failure)/TotalAttempts*100, 2)
    | eval Time = _time 
    | eval Time=strftime(Time, "%M/%H")
    | xyseries proxy, Time, Error%
    | fillnull value=0.00
    | addtotals fieldname=Totals

Instead of addtotals, I want the avg in the last column from all the rows column data over time.

0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

    base search
     | bucket _time span=1m
     | stats count(eval(success="true")) as Success,count(eval(success="false")) as Failure,
count as TotalAttempts by _time, proxy  
     | eval Error%=round(if(info="Success", Success, Failure)/TotalAttempts*100, 2)
     | eval Time = _time 
     | eval Time=strftime(Time, "%M/%H") | fillnull value=0.00
     | appendpipe [| stats avg("Error%") as "Error%" by proxy | eval Time="Total"]
     | xyseries proxy, Time, Error% | table proxy * Total

View solution in original post

somesoni2
Revered Legend

Try something like this

    base search
     | bucket _time span=1m
     | stats count(eval(success="true")) as Success,count(eval(success="false")) as Failure,
count as TotalAttempts by _time, proxy  
     | eval Error%=round(if(info="Success", Success, Failure)/TotalAttempts*100, 2)
     | eval Time = _time 
     | eval Time=strftime(Time, "%M/%H") | fillnull value=0.00
     | appendpipe [| stats avg("Error%") as "Error%" by proxy | eval Time="Total"]
     | xyseries proxy, Time, Error% | table proxy * Total

Cuyose
Builder

Awesome, this worked perfectly. Ill have to remember that appendpipe in the future.

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...