Dashboards & Visualizations

How can I pass a variable from a visualization to a datasource?

ykoer
New Member

I have multiple pie charts, each showing data from a different cluster.

I would like to define one generic datasource that gets the cluster name as an input.  Is there a possibility to define/set variables within a visualization block and pass it to a datasource? 

 

{
	"visualizations": {
		"viz_pie_chart_cluster1": {
			"type": "viz.pie",
			"dataSources": {
				"primary": "ds1"
			},
			"title": "Cluster 1",
			"options": {
				"chart.showPercent": true,
			}
			# I want to pass the cluster_name=cluster1 from this vizualization
		},
		"viz_pie_chart_cluster2": {
			"type": "viz.pie",
			"dataSources": {
				"primary": "ds1"
			},
			"title": "Cluster 2",
			"options": {
				"chart.showPercent": true,
			}
			# I want to pass the cluster_name=cluster2 from this vizualization
		}
	},
	"dataSources": {
		"ds1": {
			"type": "ds.search",
			"options": {
				"query": "... cluster_name=$cluster_name$ ..."
			},
			"name": "ds1"
		}
	}
}

 

Labels (2)
0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...