Splunk Search

Average response time, and count, by url path

hdus001
New Member

Hi,

I'm trying to create a table that shows me the number of times a URL is requested for and what its average response time is (for a given time period).

The events that contain the relevant information (url path, response time) look like this:
2014-07-02 16:04:26,716 INFO 8767 --- [p-1328426564-28] user=[ ] a.c.n.a.a.c.filters.RequestTimingFilter : Returning statusCode=[200] after time=[19ms] for method=[GET] path=[/atlas/v1/assets/adhoc/fsam/2LJT-07] queryString=[] userDn=[uid=GRAHAMHISCOCK,ou=internal users,ou=nbn,dc=nbnco,dc=com,dc=au]

In the above example, the url path is "/atlas/v1/assets/adhoc/fsam/2LJT-07" and the response time is 19 milliseconds.

The search I used is this:

path v1 | rex field=_raw "time=\[(?<responsetime>.*?)ms\]" | stats count,avg(num(responsetime)) by path

However, this seems to show me only the path and count, not average response time (this field is blank)

path count avg(num(responsetime))

[/atlas/v1/status/health] 46

[/atlas/v1/boundaries/fsam] 18

[/atlas/v1/assets/adhoc/fsam/2BLK-01] 17

Any ideas how I can obtain this information?

Thanks in advance.
Hans

Tags (2)
0 Karma

Ayn
Legend

Why use any function at all? responsetime should already be numeric if correctly extracted. If it's not correctly extracted, then that's the problem that needs to be solved.

MuS
SplunkTrust
SplunkTrust

so, now you're able to accept this as the answer 😉

0 Karma

hdus001
New Member

Yup that fixed it 🙂 ...No need to use 'num' or 'tonumber' as its already a number!

0 Karma

hdus001
New Member

Just tried the same search with 'tonumber' instead of 'num'. Still has the same problem.

0 Karma

MuS
SplunkTrust
SplunkTrust

shouldn't this avg(num(responsetime)) be like avg(tonumber(responsetime)) ?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...