Splunk Search

Search for more than 1 url hit on a src_ip

fdevera
Path Finder

Hi I have this search here where I want to limit the results to only events that have more than 1 url hit on an src_ip. How do I do that?

index=security sourcetype=malware (connect OR disconnect OR recv)
| transaction src_ip
| lookup dnslookup clientip as src_ip OUTPUT clienthost as fqdn
| rex field=fqdn "(?<hostname>[^.]+)\."
| rex field=_raw recv\:\s+User-Agent\:\s+(?<user_agent>.*)
| rex field=_raw recv\:\s+Host\:\s+(?<url>.*)
| eval url=replace(url,"\.","[.]")
| where isnotnull(url)
| table _time hostname url user_agent src_ip fqdn dest_port

 

Labels (1)
Tags (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @fdevera,

You can add it to where condition; please try below.

index=security sourcetype=malware (connect OR disconnect OR recv)
| lookup dnslookup clientip as src_ip OUTPUT clienthost as fqdn
| rex field=fqdn "(?<hostname>[^.]+)\."
| rex field=_raw recv\:\s+User-Agent\:\s+(?<user_agent>.*)
| rex field=_raw recv\:\s+Host\:\s+(?<url>.*)
| eval url=replace(url,"\.","[.]")
| where isnotnull(url)
| eventstats dc(url) as url_count by src_ip
| where url_count>1 OR url="www.badurl.com"
| transaction src_ip
| table _time hostname url user_agent src_ip fqdn dest_port url_count

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

Hi @fdevera,

You can add it to where condition; please try below.

index=security sourcetype=malware (connect OR disconnect OR recv)
| lookup dnslookup clientip as src_ip OUTPUT clienthost as fqdn
| rex field=fqdn "(?<hostname>[^.]+)\."
| rex field=_raw recv\:\s+User-Agent\:\s+(?<user_agent>.*)
| rex field=_raw recv\:\s+Host\:\s+(?<url>.*)
| eval url=replace(url,"\.","[.]")
| where isnotnull(url)
| eventstats dc(url) as url_count by src_ip
| where url_count>1 OR url="www.badurl.com"
| transaction src_ip
| table _time hostname url user_agent src_ip fqdn dest_port url_count

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

scelikok
SplunkTrust
SplunkTrust

Hi @fdevera,

Please try below;

index=security sourcetype=malware (connect OR disconnect OR recv)
| transaction src_ip
| lookup dnslookup clientip as src_ip OUTPUT clienthost as fqdn
| rex field=fqdn "(?<hostname>[^.]+)\."
| rex field=_raw recv\:\s+User-Agent\:\s+(?<user_agent>.*)
| rex field=_raw recv\:\s+Host\:\s+(?<url>.*)
| eval url=replace(url,"\.","[.]")
| where isnotnull(url)
| eventstats dc(url) as url_count by src_ip
| where url_count>1
| table _time hostname url user_agent src_ip fqdn dest_port url_count
If this reply helps you an upvote and "Accept as Solution" is appreciated.

fdevera
Path Finder

Thanks that worked. Just had to move transaction lower to get it to work:

 

 

index=security sourcetype=malware (connect OR disconnect OR recv)
| lookup dnslookup clientip as src_ip OUTPUT clienthost as fqdn
| rex field=fqdn "(?<hostname>[^.]+)\."
| rex field=_raw recv\:\s+User-Agent\:\s+(?<user_agent>.*)
| rex field=_raw recv\:\s+Host\:\s+(?<url>.*)
| eval url=replace(url,"\.","[.]")
| where isnotnull(url)
| eventstats dc(url) as url_count by src_ip
| where url_count>1
| transaction src_ip
| table _time hostname url user_agent src_ip fqdn dest_port url_count

 

 

One question though. What if there's a specific url, e.g. www.badurl.com that I don't want  to be part of the url_count>1? I want it to show in the results even though it's 1 count but the only URL that should do that.

Also this combination of url count and transaction seems to have an unwanted effect of excluding a URL (www.badurl2.com) from results even though we have multiple hits on it back to back.

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!

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...