Splunk Search

eval returns a field rather than a scalar

riley_lewis
Loves-to-Learn Lots

When I do this search:

index="mydata" | eval mymean=avg(floatnumbers) | table floatnumbers,mymean

mymean just mimics whatever is in floatnumbers. How do I calculate the mean? I have tried the fieldsummary command, but when I did that, it would not port to chart correctly.

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @riley_lewis,

the avg function must be used in a streaming command as stats or timechart:

index="mydata" 
| stats avg(floatnumbers) AS floatnumbers BY mymean

Ciao.

Giuseppe

 

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...