Splunk Cloud Platform

Developing Views and Apps for Splunk Web

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.

  1. Require the visualization registry, splunkjs/mvc/visualizationregistry.
  2. 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.
  3. Use the constructor to instantiate the visualization. Pass it an id, managerid, and an el.

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();
});
Last modified on 26 March, 2021
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)


Was this topic useful?







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