After you've taken care of the requirements, you're ready to install the components of the Splunk SDK for JavaScript.
The Splunk SDK for JavaScript includes pre-built client-side files that run in a web browser. To install the client-side files, you just need to copy them to your site and include them in your code. The client-side SDK also uses the jQuery library, so you also need jquery.min.js.
To install the client-side files
<script type="text/javascript" src="/YOUR_PATH/splunk.js"></script>
Or:
<script type="text/javascript" src="/YOUR_PATH/splunk.min.js"></script>
This tag creates a global variable called splunkjs, which is the root of the SDK. No other global variables are introduced.
<script type="text/javascript" src="/YOUR_PATH/jquery.min.js"></script>
The Splunk SDK for JavaScript requires Node.js for server-side scripting. To use the Splunk SDK for JavaScript in your own Node.js programs, install the server-side files and require them in your script.
To install the server-side files
npm install splunk-sdk
var splunkjs = require('splunk-sdk');
Note This app is only required for Splunk 4.2.x or 4.3.x, or if you want to run the unit tests (with any Splunk version).
JavaScript uses the JavaScript Object Notation (JSON) format for structured data. The Splunk SDK for JavaScript provides a Splunk app, xml2json, that converts the XML that Splunk returns into JSON.
To install the xml2json app
The following examples show how to do this at the command line.
On Mac OS X: To copy the xml2json directory to the Splunk apps directory, go to the /splunk-sdk-javascript directory and enter:
cp -r xml2json /applications/splunk/etc/apps/xml2json
Or, to create a symbolic link to the xml2json directory, enter:
ln -s /users/currentusername/splunk-sdk-javascript/xml2json /applications/splunk/etc/apps/xml2json
On Windows: To copy the xml2json directory to the Splunk apps directory, enter:
xcopy C:\splunk-sdk-javascript\xml2json "C:\Program Files\Splunk\etc\apps \xml2json" /s
On Mac OS X: Go to the /Applications/splunk/bin directory and enter:
./splunk restart
On Windows: Go to the C:\Program Files\Splunk\bin directory and enter:
splunk restart