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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...