Splunk Search

Distinct count when grouped events meet certain criteria

monkey
Explorer

Hi there,

I can't for the life of me figure out how to do the following.

I'm analysing some standard web logs.

I want to be able to find out when any unique IP address accesses a particular URI path more than once a second.

The starting point I have for this is as follows:

uri_path=/foo | span=1s timechart dc(clientip)

This shows me when the distinct count of IP addresses accessing this URL per 1 second intervals BUT it includes all instances where the requests are made just once during this span. I only want a distinct count of the IP addresses that requested the URL more than once in the 1 second span.

Does anyone have any idea how to do this?

Many thanks.

Tags (1)

yannK
Splunk Employee
Splunk Employee

Add a filter condition after :

uri_path=/foo | span=1s timechart dc(clientip) AS distinct_ip | where distinct_ip >1

yannK
Splunk Employee
Splunk Employee

did it worked for you ?

0 Karma

yannK
Splunk Employee
Splunk Employee

ok so you want how many time EACH distinct ip connects in a 1 second windows. exclude all the ones that connected only one,
then count the number of those distinct ips per second.

uri_path=/foo 
| bucket _time span=1s 
| stats count by _time clientip 
| where count >1 
| timechart span=1s dc(clientip) as distinct_ip
0 Karma

monkey
Explorer

Thanks, yannK, but that doesn't quite achieve what I want: it charts data when more than one distinct client IP appears in one second. I only want to chart the count of distinct client IPs where the count of each distinct client IP is more than one.

192.168.1.1
192.168.1.1
192.168.2.2

I.e. if the above client IPs appear in one second, I want to chart "1" for that second (since 192.168.1.1 appears twice).

192.168.1.1
192.168.2.2
192.168.3.3

If the above appear in one second, I want to chart "0" for that second.

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 ...