Load libraries and configure SplunkJS Stack for apps outside of Splunk Web

To integrate Splunk into your own web applications, load the SplunkJS Stack libraries and configure SplunkJS Stack in your web pages as follows.

  • Include the Bootstrap.css style sheet, which is required by Web Framework views to function properly. For example:
  • <link rel="stylesheet" type="text/css" href="yourstaticdirectory/splunkjs/css/bootstrap.css"/>
    
  • Load the SplunkJS Stack libraries. For example:
  • <script src="yourstaticdirectory/splunkjs/config.js"></script>
    
  • Configure SplunkJS Stack by specifying properties as a dictionary of key-value pairs. For a description of the possible properties you can set, see "SplunkJSConfig" in the Splunk Web Framework Component Reference. At a minimum, you need to specify an authenticate function to authenticate users with the Splunk server.
  • Here's an example of a SplunkJS Stack configuration:

    splunkjs.config({
        proxyPath: "/proxy",
        scheme: "https",
        host: "localhost",
        port: 8089,
        authenticate: function(done) {
            // TO DO: Custom authentication function
        },
        onSessionExpired: function (authenticate, done) {
            // TO DO: Custom session expiration function
        },
        onDrilldown: function(drilldown) {
            // TO DO: Custom drilldown action
        }
    });
    

    For more about authentication, see Authenticate users for apps outside of Splunk Web. For more about drilldown, see Customize drilldown actions.

  • Set the base URL for your website. For example:
  • require.config({
        baseUrl: yourbaseurl
    });

For code examples that use SplunkJS Stack, see Splunk Web Framework code examples.