Splunk® Enterprise

Developing Views and Apps for Splunk Web

Download manual as PDF

Download topic as PDF

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.


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();
});
PREVIOUS
Custom visualizations in Simple XML
  NEXT
Custom alert actions overview

This documentation applies to the following versions of Splunk® Enterprise: 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.5.0, 6.5.1, 6.5.1612 (Splunk Cloud only), 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.6.0, 6.6.1, 6.6.2, 6.6.3


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

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