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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...