Splunk Search

Average of a field

saranyaa21
Path Finder

Hi,

I have a log trace like, ...........................wages: 50

I have written a splunk query to skip all the entries before "wages:" and print only the values like 50, 30, whatever.

sourcetype=mysource host=myhost* "myClassName" | rex field=_raw "(?<"ac">(?<=wages:).*?$)" | stats count by ac

Now, I'm not able to find the median/ average of the values in ac.
Eg: (50+50)/2

Can you please help me in obtaining this value.

Thanks

Tags (2)
0 Karma

Vijeta
Influencer

you can do |stats avg(ac)

0 Karma

saranyaa21
Path Finder

No it dint work 😞

0 Karma

saranyaa21
Path Finder

It is displaying nothing

0 Karma

Vijeta
Influencer

Did you check if you are getting any values in ac, just see what below gives you

sourcetype=mysource host=myhost* "myClassName" | rex field=_raw "(?<"ac">(?<=wages:).*?$)" | table ac

0 Karma

saranyaa21
Path Finder

Yes, the query sourcetype=mysource host=myhost* "myClassName" | rex field=_raw "(?<"ac">(?<=wages:).*?$)" | table ac , returns me some values, like, 30, 50, etc.,

but when i give stats avg(ac), it doesn't return any result

0 Karma

sduff_splunk
Splunk Employee
Splunk Employee

sourcetype=mysource host=myhost* "myClassName" | rex field=_raw "(?<"ac">(?<=wages:).*?$)" | stats avg(ac)

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...