Custom visualizations in SplunkJS
Custom visualization components registered with the system are accessible from SplunkJS.
Visualizations published in an app can be used in SplunkJS dashboard extensions and SplunkJS pages. Apps can use their own visualizations in SplunkJS as well as visualizations from other installed apps. Custom visualizations that are built in the Splunk platform can be reused only within a Splunk software environment.
Access and instantiate a visualization
Here are the steps for accessing and instantiating a visualization from a SplunkJS page.
- Require the visualization registry,
splunkjs/mvc/visualizationregistry
. - Call
visualizationregistry.getVisualizer(<app_name>, <visualization_name>)
. Use the name of the app that contains the visualization and the visualization name. The function returns a constructor. - Use the constructor to instantiate the visualization. Pass it an
id
,managerid
, and anel
.
Example
This example SplunkJS page instantiates the customViz
visualization from an app called viz_sample_app
. The visualization renders in a div
with the id content
.
require([ 'jquery', 'splunkjs/ready!', 'splunkjs/mvc/visualizationregistry', 'splunkjs/mvc/searchmanager' ], function($, mvc, VisualizationRegistry, SearchManager){ var customViz = VisualizationRegistry.getVisualizer('viz_sample_app', 'customViz'); var mainManager = new SearchManager({ id: 'mainManager', search: 'index = _internal | stats count' }); var myViz = new customViz({ id: 'myViz', managerid: 'mainManager', el: $('#content') }).render(); });
Custom visualizations in Simple XML | Custom alert actions overview |
This documentation applies to the following versions of Splunk Cloud Platform™: 8.2.2112, 8.2.2201, 8.2.2202, 8.2.2203, 9.0.2205, 9.0.2208, 9.0.2209, 9.0.2303, 9.0.2305, 9.1.2308, 9.1.2312, 9.2.2403, 9.2.2406 (latest FedRAMP release)
Feedback submitted, thanks!