Constructor for splunkjs.StormService
.
Constructor for splunkjs.StormService
.
Name | Type | Description |
---|---|---|
http | splunkjs.Http | An instance of a |
params | Object | A dictionary of parameters: |
A new splunkjs.StormService
instance.
init: function(http, params) {
if (!(http instanceof Http) && !params) {
// Move over the params
params = http;
http = null;
}
params = params || {};
var username = params.token || params.username || null;
var password = "x";
// Set up the parameters
params.paths = Paths.storm;
params.scheme = "https";
params.host = "api.splunkstorm.com";
params.port = 443;
params.sessionKey = base64.encode(username + ":x");
params.authorization = "Basic";
// Initialize
this._super.call(this, http, params);
// Override computed parameters
this.prefix = this.scheme + "://" + this.host + ":" + this.port + "/1";
},
Logs an event to Splunk Storm.
Name | Type | Description |
---|---|---|
event | String,Object | The text for this event or an object that will be converted to JSON. |
params | Object | A dictionary of parameters for indexing: |
callback | Function | A function to call when the event is submitted: |
storm.log(
"MY AWESOME LOG MESSAGE",
{project: "XYZ123", sourcetype: "GO"},
function(err, response) {
console.log("DATA IS IN STORM!");
}
);
log: function(event, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
if (!params.project && !params.index) {
throw new Error("Cannot submit events to Storm without specifying a project");
}
if (params.project) {
params.index = params.project;
delete params["project"];
}
if (utils.isObject(event)) {
event = JSON.stringify(event);
}
return this._super(event, params, callback);
}
});
})();