Splunk Search

Query to search for huge set of URLs

rbathla
New Member

I have close to 2000 URLs I want to search in one source. Is it possible to do it in one query by using lookup and what is the query?

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

You need to add those URLs in a csv file, say filterurl.csv with header as url, and add filterurl.csv as lookup table file in Splunk. Now try this,

if your data from that source has a field called url (same name as in lookup table) based on which you want to filter:

index=yourindex sourcetype=yoursourcetype source=yoursource [| inputlookup filterurl.csv | table url ]

if your data from that source has a field called myurl (different name as in lookup table) based on which you want to filter:

index=yourindex sourcetype=yoursourcetype source=yoursource [| inputlookup filterurl.csv | table url | rename url as myurl]

if your data doesn't have the field extracted and you want to do text based filter

index=yourindex sourcetype=yoursourcetype source=yoursource [| inputlookup filterurl.csv | table url | rename url as search]

View solution in original post

0 Karma

DalJeanis
Legend

Somesoni2's answer is correct to what is technically possible.

The caution required is that, if you have a set of 2000 URLs that you are going to be searching for, though your entire source, then unless that is an indexed field, that search is likely to take slightly less than forever. Be sure to test with a lookup table of, say, 50 URLs across a limited time period where you know at least a few events should be, before submitting a search that might suck enough power to dim the lights.

0 Karma

somesoni2
Revered Legend

You need to add those URLs in a csv file, say filterurl.csv with header as url, and add filterurl.csv as lookup table file in Splunk. Now try this,

if your data from that source has a field called url (same name as in lookup table) based on which you want to filter:

index=yourindex sourcetype=yoursourcetype source=yoursource [| inputlookup filterurl.csv | table url ]

if your data from that source has a field called myurl (different name as in lookup table) based on which you want to filter:

index=yourindex sourcetype=yoursourcetype source=yoursource [| inputlookup filterurl.csv | table url | rename url as myurl]

if your data doesn't have the field extracted and you want to do text based filter

index=yourindex sourcetype=yoursourcetype source=yoursource [| inputlookup filterurl.csv | table url | rename url as search]
0 Karma

rbathla
New Member

This was awesome. It worked. I am doing it in chunk of 500 and it is working.
Really appreciate the help always provided on the forum.

0 Karma

Richfez
SplunkTrust
SplunkTrust

Since that worked, could you please Accept somesoni2's answer? That will help future searchers find this easier and better!

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...