Code examples using the Splunk Web Framework

This section provides end-to-end code examples for developing Splunk apps, showing how to set up and work with views and search managers using the different components of the Splunk Web Framework.

 

Simple XML extensions

These examples show how to add CSS and JavaScript as extensions to Simple XML dashboards.

Code exampleDescription
Basic dashboardA basic template with a chart and an events viewer displaying results from a search.
A collection of views on one pageDisplays the most common views on one page. Shows how to sync search controls to a search manager and how to populate form controls with static choices and search-based choices.
ChartsShows examples of each of the possible chart types.
Tables with custom renderersShows how to display a table that includes a sparkline in the search results, a custom cell renderer, and a custom row renderer.
Events viewersShows examples of each of the possible types of events viewer.
MapsShows data displayed on a Splunk map.
Drilldown propertiesShows the result of setting different combinations of drilldown properties for the views that allow drilldown actions.
Search controls using tokensShows how to use tokens to sync search controls to a search manager.
Search controls using eventsShows how to use change events to sync search controls to a search manager.
Search progress eventsShows how to retrieve the progress of a search, including the status of the search and the properties of the search job.
Search results modelShows how to retrieve the different types of search results from the results model: events, preview, results, and summary.
Token manipulationShows how to use tokens to run a search using the index value that is selected from a dropdown list. Tokens are manipulated using the token change event handler.
Token transform and forwardingShows different ways to change a token value by using token filters and forwarders.
 

HTML dashboards

These examples show how to use HTML dashboards.

Code exampleDescription
Tables with custom renderersShows how to display a table that includes a sparkline in the search results, a custom cell renderer, and a custom row renderer.
MapsShows data displayed on a Splunk map.
Drilldown propertiesShows the result of setting different combinations of drilldown properties for the views that allow drilldown actions.
Search progress eventsShows how to retrieve the progress of a search, including the status of the search and the properties of the search job.
Search results modelShows how to retrieve the different types of search results from the results model: events, preview, results, and summary.
Search controls using tokensShows how to use tokens to sync search controls to a search manager.
Search controls using eventsShows how to use change events to sync search controls to a search manager.
Token manipulationShows how to use tokens to run a search using the index value that is selected from a dropdown list. Tokens are manipulated using the token change event handler.
Token transform and forwardingShows different ways to change a token value by using token filters and forwarders.
 

SplunkJS Stack for apps outside Splunk Web

These JavaScript examples show how to use SplunkJS Stack in an app outside of Splunk Web.

Code exampleDescription
Login formA login form that shows how to log in to Splunk and get a session key using the Splunk SDK for JavaScript.
Basic pageA basic page with a chart and an events viewer displaying results from a search.
Basic page with a layoutThe same basic page as above, but with a Splunk Dashboard (dashboard.css) layout.
A collection of views on one pageDisplays the most common views on one page. Shows how to sync search controls to a search manager and how to populate form controls with static choices and search-based choices.
ChartsShows examples of each of the possible chart types.
Tables with custom renderersShows how to display a table that includes a sparkline in the search results, a custom cell renderer, and a custom row renderer.
Events viewersShows examples of each of the possible types of events viewer.
MapsShows the same data displayed on a Splunk map and a Google map.
Drilldown propertiesShows the result of setting different combinations of drilldown properties for the views that allow drilldown actions.
Search controls using tokensShows how to use tokens to sync search controls to a search manager.
Search controls using eventsShows how to use change events to sync search controls to a search manager.
Search progress eventsShows how to retrieve the progress of a search, including the status of the search and the properties of the search job.
Search results modelShows how to retrieve the different types of search results from the results model: events, preview, results, and summary.
 

Same dashboard using different tools

These examples show how to use each of the different Web Framework tools to create the same dashboard. The starting point is a Simple XML dashboard created in Splunk Web, which is then converted to HTML and modified. The same modifications are made using a Simple XML extension.

Code exampleDescription
Simple XMLA Simple XML dashboard created in Splunk Web using the Dashboard Editor.
HTML DashboardAn HTML dashboard created by converting the Simple XML to HTML.
Modified HTML DashboardA modified version of the HTML dashboard created above.
Simple XML extensionA simple XML extension, created using JavaScript and CSS. The resulting dashboard is the same as the modified HTML dashboard.