curl -k -u admin:changeme https://localhost:8089/services/auth/login -d username=admin -d password=changeme
http://dev.splunk.com/view/SP-CAAAEWS
http://docs.splunk.com/Documentation/Splunk/6.6.2/RESTREF/RESTaccess#auth.2Flogin
.main-area {
padding: 30px;
}
This example shows how to set up SearchBar and SearchControls views using Django tags, and sync them with a SearchManager using tokens.
Note: The Timeline view can't be synced using tokens. Use events instead.
// Configure SplunkJS Stack
splunkjs.config({
scheme: 'https',
host: '192.168.1.6',
port: 8089,
authenticate: {username: 'admin', password: 'abcd'},
});
/* splunkjs.config({
scheme: "https",
host: "localhost",
port: 8089,
authenticate: function(done) {
require([
"jquery",
"jquery.cookie"
], function($) {
// Retrieve the session key and username from cookies
var splunkSessionKey = $.cookie("splunk_sessionkey");
var splunkCurrentUser = $.cookie("splunk_username");
// Log in using the session key and username
if (splunkSessionKey) {
done(null, {sessionKey: splunkSessionKey, username: splunkCurrentUser});
}
// If there is no session key, redirect to the login form
else {
window.location.replace("login_form.html");
}
});
}
}); */
// Configure the web site's base URL
require.config({
baseUrl: "static/"
});
// Set up the Web Framework components
var deps = [
"splunkjs/ready!",
"splunkjs/mvc/searchmanager",
"splunkjs/mvc/searchbarview",
"splunkjs/mvc/searchcontrolsview",
"splunkjs/mvc/tableview"
];
require(deps, function(mvc) {
// Load individual components
var SearchManager = require("splunkjs/mvc/searchmanager");
var SearchbarView = require("splunkjs/mvc/searchbarview");
var SearchControlsView = require("splunkjs/mvc/searchcontrolsview");
var TableView = require("splunkjs/mvc/tableview");
// Create the search manager and views
var mysearch = new SearchManager({
id: "search1",
search: mvc.tokenSafe("$searchquery$"),
earliest_time: mvc.tokenSafe("$earlyval$"),
latest_time: mvc.tokenSafe("$lateval$"),
app: "search",
preview: true,
required_field_list: "*",
status_buckets: 300
});
var mysearchbar = new SearchbarView({
id: "searchbar1",
managerid: "search1",
value: mvc.tokenSafe("$searchquery$"),
timerange_earliest_time: mvc.tokenSafe("$earlyval$"),
timerange_latest_time: mvc.tokenSafe("$lateval$"),
default: "index=_internal | head 100",
el: $("#mysearchbar1")
}).render();
var mysearchcontrols = new SearchControlsView({
id: "searchcontrols1",
managerid: "search1",
el: $("#mysearchcontrols1")
}).render();
var mytable = new TableView({
id: "table1",
managerid: "search1",
el: $("#mytable1")
}).render();
});