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!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...