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
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...