Splunk Search

Slow Response DNS Lookup Thousands of IPs

albyva
Communicator

I am running a DNS lookup on IP addresses using the following arrangement, but it is running very, very, very, slow because the initial input is thousands of IPs.

index=generic
| eval minute=strftime(_time, "%H:%M")
| stats sum(bytes) as totalbytes by dest_ip, minute
| eval Mbps=round(totalbytes/1024/1024)
| rename dest_ip as clientip
| lookup dnslookup clientip
| rename clienthost as destination
| table minute, Mbps, clientip, destination
| sort -Mbps
| head 10

Is there anyway this could be rewritten to speed up the Lookup process so that only the Top 10 address are run through Lookup and not the thousands I initially query?

My goal is just to really run the DNS lookup on the Top 10 addresses. But when I move
(head 10) in front of Lookup or Table, it doesn't give me the Top 10 from the Table/Sort.
Maybe this is a Splunk hierarchy problem or maybe I need a whole rewrite.
Any help is appreciated.

Tags (5)
0 Karma
1 Solution

Ayn
Legend

No, it's because you're moving head before the sort statement. Before you've sorted the events, Splunk will just grab the 10 first entries in whatever order they happen to come in (reverse chronologically). If you do this

index=generic | eval minute=strftime(_time, "%H:%M") | stats sum(bytes) as totalbytes by dest_ip, minute | eval Mbps=round(totalbytes/1024/1024) | sort -Mbps | head 10 | rename dest_ip as clientip | lookup dnslookup clientip | rename clienthost as destination | table minute, Mbps, clientip, destination

You should get the results you want.

View solution in original post

lakromani
Builder

this part

| rename dest_ip as clientip
| lookup dnslookup clientip
| rename clienthost as destination

could be done in one command

| lookup dnslookup clientip as dest_ip output clienthost as destination
0 Karma

Ayn
Legend

No, it's because you're moving head before the sort statement. Before you've sorted the events, Splunk will just grab the 10 first entries in whatever order they happen to come in (reverse chronologically). If you do this

index=generic | eval minute=strftime(_time, "%H:%M") | stats sum(bytes) as totalbytes by dest_ip, minute | eval Mbps=round(totalbytes/1024/1024) | sort -Mbps | head 10 | rename dest_ip as clientip | lookup dnslookup clientip | rename clienthost as destination | table minute, Mbps, clientip, destination

You should get the results you want.

albyva
Communicator

w00t. Worked like a charm. Thanks a million

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...