Splunk Search

Need to run a subsearch with practically unlimited rows

anthony_copus
Explorer

Hi,

Currently I'm trying to run a query which take the results of a subsearch as a parameter as follows:

index="video" [search index=page article_id!="" type=d | stats count by article_id | fields article_id] | stats count by platform

So the aim is to retrieve all the count from the video index which have the same article_id values which are retrieved from the subsearch. However, the subsearch should return a vast amount of results (well over 10000) so this method doesn't seem too practical.

Is there a better method of achieving the same ends or a solution to the limit which would be more than simply raising it a little?

Anthony

0 Karma

DalJeanis
Legend

You can do it without a subsearch at all. This looks a little inelegant, so it can probably be coded a bit tighter, but here's some unlimited code that ought to get you the same result as yours...

(index="video" article_id!="") or (index="page" article_id!="" type=d)
| table index article_id type platform
| fillnull value="" type platform
| stats count as itemcount, list(platform) as platform, list(type) as type by article_id index
| eval platform=if(platform="",null(),platform)
| eval type=if(type="",null(),type)
| eval itemcount=if(index="page", 0,itemcount)
| stats sum(itemcount) as itemcount, list(platform) as platform, values(type) as type by article_id
| search type=d
| stats sum(itemcount) as count, by platform

The above is based on the assumption that your video records (effectively) contain three fields - index=video, article_id=somevalue, and platform=someothervalue (no type). Likewise, your page records contain index=page, article_id=somevalue, and type=d (no platform), and that you only want records from video when the article_id is on a type d record in the page index.

0 Karma

somesoni2
Revered Legend

Try updating following in your limits.conf. (need restart)

[subsearch] 
maxout = 50000

[format] 
maxresults = 50000

aweitzman
Motivator

map might be of use here:

index=page article_id!="" type=d | dedup article_id | table article_id | map search="search index=video article_id=$article_id$ | stats count by platform" maxsearches=1000000

(I changed the first stats count to dedup since you don't seem to be doing anything with the count coming from the page index, so you can avoid wasting the resources computing it.)

Note: This search may take a very, very long time. Be prepared.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...