Splunk® Dashboards App

Splunk Dashboards app (beta) for Enterprise and Cloud

Acrobat logo Download manual as PDF


Acrobat logo Download topic as PDF

Use ds.search to create search-based visualizations

The data source type ds.search is used for ad hoc searches that you create in the visual editor. If you want to use a saved search, see Use ds.savedSearch to use reports and saved searches.

The ds.search data source is assigned a unique ID when you create a search string in the Configuration panel and the source code stanza and is followed by the data source type, and any options you have made available.

The only option that must return events is the query option, which is an SPL search.

For example, the following data source uses the search

index=_internal | head 500

to return results that can be displayed by adding the ID of the data source, "BCsearch", to a visualization module as its primary data source.

{
"dataSources": {
	"BCsearch": {
		"type": "ds.search",
		"options": {
			"query": "index=_internal | head 500",
			"queryParameters": {
				"earliest": "0",
				"latest": "now"
			}
               }
     }

The following is an example of a visualization using BCsearch as the primary dataSource .

{
"visualizations": {
	"viz_AHAavFGS": {
		"type": "viz.table",
		"options": {
			"backgroundColor": "#0000FF",
                               "fontColor": "#0000FF"
		},
		"dataSources": {
			"primary": "BCsearch"
		}
	} 

The visualization must also appear in the layout. The following is a complete dashboard example using the two stanzas above.


{
"dataSources": {
	"BCsearch": {
		"type": "ds.search",
		"options": {
			"query": "index=_internal | head 500",
			"queryParameters": {
				"earliest": "0",
				"latest": ""
			}
		}
	}
},
"visualizations": {
	"viz_Example": {
		"type": "viz.table",
		"options": {},
		"dataSources": {
			"primary": "BCsearch"
		}
	}
},
"inputs": {},
"layout": {
	"globalInputs": [],
	"type": "absolute",
	"options": {
		"width": 1801
	},
	"structure": [
		{
			"item": "viz_Example",
			"type": "block",
			"position": {
				"x": 10,
				"y": 50,
				"w": 1270,
				"h": 600
			}
		}
	]
},
"description": "",
"title": "Example",
"defaults": {
	"visualizations": {
		"global": {
			"showLastUpdated": true
		  }
	    }
       }
}


The resulting table visualization looks similar to this:

A table visualization using a search based data source.

If you are using lookups in your search, make sure the lookup permissions are set to "global".

Last modified on 17 December, 2020
PREVIOUS
How to format JSON stanzas
  NEXT
Use a ds.chain search with a base search to chain searches together

This documentation applies to the following versions of Splunk® Dashboards App: 0.8.0, 0.9.0


Was this documentation topic helpful?


You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters