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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...