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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...