Browser (client) examples in the Splunk SDK for JavaScript

The Splunk® SDK for JavaScript includes several examples that run in the browser with your own instance of Splunk, and are located in the /splunk-sdk-javascript/examples/browser directory. Node.js is required to run these examples. We recommend opening the developer console while you run the examples to see what requests the Splunk SDK for JavaScript is making.

  • The Hello World examples (/helloworld/index.html) contain simple examples that focus on one feature and require little or no configuration, such as listing apps, listing saves searches and their queries, and creating different types of searches and getting their results. Some examples use the Splunk.Async module to make asynchronous control-flow easier.
  • The UI example (/UI/index.html) lets you access the Timeline control and Charting control, the same ones that Splunk Web uses in version 4.3. Go ahead and see your data by looking at your event timeline and charting your queries.
  • The Visualization example (/Viz/index.html) shows how to integrate with third-party visualization tools:
    • Google Charts, a simple but powerful charting library from Google.
    • Rickshaw, a time series visualization library based on d3. (This doesn't work in Internet Explorer 9 though.)
  • MiniSplunk is a complex full-application example that mimics much of the core functionality of Splunk. You can search, manage jobs, and even see a map of the search results that have geo data.

These examples work around a couple of issues—because Splunkd is not on the same host as the web server that serves your page, and because of the browser's Single Origin Policy, we provide all the parameters to the sample web server, which proxies them to Splunkd. (That's what those ProxyHttp lines are all about. See Dependencies and cross-domain communication for more.)

Run the Index.html example

To start the development webserver and display the example Index.html page in your browser, open a command prompt in the /splunk-sdk-javascript directory and enter:

node sdkdo examples

Or, to start the server manually enter:

node sdkdo runserver

And then in a browser, open http://localhost:6969/examples/browser/index.html.