Splunk Search

Is it possible to run two separate searches on a Inputlookup CSV to use the first/last X amount of results?

UMDTERPS
Communicator

I am looking to run two searches on a CSV, one that looks at the first 35,000 results and another that looks at the last 35,000 results. The easiest way to solve the problem would be to increase the subsearch limit to 100,000, however, the admin is refusing to do so. Another way would be to chop the CSV in half and run the same search twice.

Is there a command or search in Splunk that can look at the first 35,000 results and another that looks at the last 35,000 results of a lookup?

Would using head and tail be the best way? (however, the total results may change every day/week)

Thanks!

0 Karma
1 Solution

UMDTERPS
Communicator

Okay, figured it out:

|inputlookup ip_dump.csv 
| streamstats count("IP Address") as row_number
| where row_number <= 50000
| append [
    |inputlookup ip_dump.csv 
    | streamstats count("IP Address") as row_number
    | where row_number > 50000]

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Totally untested, but you might try this.

| multisearch [|inputlookup something.csv | head 35000] [|inputlookup something.csv | tail 35000] | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

UMDTERPS
Communicator

I think the union command can be used too?:

| union maxout=10000000
[ search index=union_1 | head 60000]
[ search index=union_1 | tail 40000]

https://docs.splunk.com/Documentation/Splunk/8.0.1/SearchReference/Union

0 Karma

UMDTERPS
Communicator

Okay, figured it out:

|inputlookup ip_dump.csv 
| streamstats count("IP Address") as row_number
| where row_number <= 50000
| append [
    |inputlookup ip_dump.csv 
    | streamstats count("IP Address") as row_number
    | where row_number > 50000]
0 Karma

somesoni2
Revered Legend

Give this workaroud a try (single search with no subsearch)

| inputlookup yourlookup.csv 
| streamstats count as fwd_sno
| reverse 
| streamstats count as rev_sno
| reverse
| where fwd_sno<=35000 OR rev_sno<=35000

Basically adding two serial number columns, one in up to down and second down to up. Then selecting first 35000 rows in either serial number.

0 Karma

UMDTERPS
Communicator

I think this would work too! =0)

Thanks!

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