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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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