Splunk Search

count events per user, showing average latency

tmarlette
Motivator

I am attempting to count the number of times a user has made a web server 'hit', and also display the average latency of that/those users.

Search Query:

sourcetype=www NOT hck=* user=< user > | stats avg(time_taken) as "latency(1s)" | stats count(user) by latency(1s)

I can't seem to get the fields to come out right, either I get just the latency, or the count and the latency without the user.

Tags (3)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

should work,

sourcetype=www NOT hck=* user=< user > | eventstats avg(time_taken) as latency | stats count(user) by latency | rename latency as "latency (1s)"

UPDATE:

perhaps this is what you're after:

sourcetype=www NOT hck=* user=* | stats count as hits, avg(time_taken) as "latency(1s)" by user

/k

View solution in original post

0 Karma

kristian_kolb
Ultra Champion

should work,

sourcetype=www NOT hck=* user=< user > | eventstats avg(time_taken) as latency | stats count(user) by latency | rename latency as "latency (1s)"

UPDATE:

perhaps this is what you're after:

sourcetype=www NOT hck=* user=* | stats count as hits, avg(time_taken) as "latency(1s)" by user

/k

0 Karma

tmarlette
Motivator

Actually I just tweeked this a little bit, but you were pretty much spot on. Here is the final search:
sourcetype=www NOT hck=* | eval user=user."@".domain | stats count as hits, avg(time_taken) as "avg latency(1s)" by user | sort - "avg latency(1s)"

0 Karma

kristian_kolb
Ultra Champion

Or wait. That does not seem right. What do you really want? Provide sample events and sketch of desired output, please

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...