Chain searches together with a base search and chain searches

Optimize computing resources by using a base search to drive multiple chain searches, reducing redundancy and enhancing efficiency in large dashboards with shared initial search sections.

When you use a separate search for each visualization on a large dashboard, you can use a lot of computing power. When these searches begin with the same initial SPL search sections, you can use these sections as a base search, then branch the base search into additional chained data source searches that drive the same visualizations, using less computing power because the base search only runs once for all of the visualizations. You can do this directly in the UI.

For example, consider that 3 data sources have the following 3 searches, which begin with the same first 2 search sections:

Search 1
CODE
Search 2
CODE
Search 3
CODE

You can create 2 data sources of type ds.chain that branch from an existing base search. For example:

Chain search 1
CODE
Chain search 2
CODE

You can further branch a chain search by 1 additional search. For example:

Chain search 2a
CODE
Chain search 2b
CODE

Create a base search

Configure a base search as a data source for your visualization by selecting or creating a search and defining its SPL query.

Connect a base search to a chain search

Connect a base search to a chain search, configure a chain search data source, and manage comments and pipes in chained SPL queries.

Example

Learn how to build and extend chained searches from a base search, including branching rules, token usage, and inherited properties in Splunk dashboards.

There are many different combinations you can use once you've established the base search, for example:

The base search becomes:
CODE
Search 1 is now the following: base search + Chain search 1

Search 2 is now the following: base search + Chain search 2 + Chain search 2a

Search 3 is now the following: base search + Chain search 2 + Chain search 2b

You can extend, or branch, many independent chain searches from the base search, and you can extend many second level chains that use the first level chain as their primary data source, but you cannot have a third level of chains that use the a second level chain as a primary data source.

This functionality is similar to the way that you might have used post-process searches using Simple XML.

You can use tokens in base and chain searches. Any token you create can be used in a search of type ds.chain, but time-related tokens can only be used in the base search.

Note: You cannot specify any properties such as queryParameters, refresh, and refreshType for chain searches. These are inherited from those set in the base search or from settings in the defaults section. When a base search refreshes or its SPL search is changed, the associated chain searches also refresh.

Chain search anatomy example

Learn how a base search and chained searches work together in a dashboard, including visualization layout and data source configuration details.

Best practices for creating chain searches

Learn how to design efficient, reliable chain searches by choosing appropriate base searches, limiting results and complexity, and avoiding common performance and timeout issues.

Use these best practices to ensure that chain searches work as expected.

Fixing search result and timeout issues

Non-transforming base searches can cause search result and timeout issues. If you observe the following issues in a dashboard, check the base search to make sure that it is a transforming search:

  • no results returned
  • event retention
  • client timeout
  • the collect command

No results returned

If the base search is a non-transforming search, you must explicitly state in the base search what fields to use in the chain search using the | fields command. For example, if your chain search searches for the top selling Buttercup game categories over time, use a search command similar to the following.

| fields _time, categoryId, action

Event retention

If the base search is a non-transforming search, the Splunk platform retains only the first 500,000 events that it returns. A chain search does not process events in excess of this 500,000 event limit, silently ignoring them. This can generate incomplete data for the chain search.

This search result retention limit matches the max_count setting in limits.conf. The setting default is 500,000.

Client timeout

If the chain search takes too long, it can exceed the Splunk Web client timeout value of 30 seconds.

The collect command

The collect command does not work with chain searches when used in the base search.

For information about transforming searches, see transforming commands and searches in the Search Manual.

Utilize fewer base searches

Using fewer base searches can improve your dashboard's performance. For example, one base search is often more efficient than multiple base searches.

Limit base search results and chain complexity

Passing a large number of search results to a chain search can cause server timeout issues. In this scenario, consider adjusting the base search to reduce the number of results and fields that it returns. You can also consider reducing the complexity of chain searches on the base search results.

You can use a single chain search from a base search to generate results or you can generate multiple chain searches together.

Base and chain refresh behavior

Specific changes occurring in a base or chain will impact the refresh behavior of the base and chain. The following describes the actions that initiate a refresh on a base, chain, or both.

Description Refresh behavior
Token value changes in the base. Entire base and chain tree refreshes.
Token value changes in only the chain. No change occurs in the base. Only the chain search refreshes. The base does not refresh.
Auto refresh interval is set on a base or chain. Entire base and chain tree refreshes.
Manual refresh is triggered on a base or chain. Entire base and chain tree refreshes.