Package Exports
- splunk-logging
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (splunk-logging) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Splunk logging for JavaScript
Version 0.11.1
This project provides a simple JavaScript interface for logging to HTTP Event Collector in Splunk Enterprise and Splunk Cloud.
Requirements
- Node.js v4 or later. Splunk logging for Javascript is tested with Node.js v10.0 and v14.0.
- Splunk Enterprise 6.3.0 or later, or Splunk Cloud. Splunk logging for Javascript is tested with Splunk Enterprise 8.0 and 8.2.0.
- An HTTP Event Collector token from your Splunk Enterprise server.
Installation
First, update npm to the latest version by running:
sudo npm install npm -gThen run:
npm install --save splunk-loggingUsage
See the examples folder for usage examples:
all_batching.js: Shows how to configure a logger with the 3 batching settings:batchInterval,maxBatchCount, &maxBatchSize.basic.js: Shows how to configure a logger and send a log message to Splunk.custom_format.js: Shows how to configure a logger to log messages to Splunk using a custom format.manual_batching.js: Shows how to queue log messages, and send them in batches by manually callingflush().retry.js: Shows how to configure retries on errors.
SSL
Note: SSL certificate validation is disabled by default.
To enable it, set requestOptions.strictSSL = true on your SplunkLogger instance:
var SplunkLogger = require("splunk-logging").Logger;
var config = {
token: "your-token-here",
url: "https://splunk.local:8088"
};
var Logger = new SplunkLogger(config);
// Enable SSL certificate validation
Logger.requestOptions.strictSSL = true;Basic example
var SplunkLogger = require("splunk-logging").Logger;
var config = {
token: "your-token-here",
url: "https://splunk.local:8088"
};
var Logger = new SplunkLogger(config);
var payload = {
// Message can be anything; doesn't have to be an object
message: {
temperature: "70F",
chickenCount: 500
}
};
console.log("Sending payload", payload);
Logger.send(payload, function(err, resp, body) {
// If successful, body will be { text: 'Success', code: 0 }
console.log("Response from Splunk", body);
});Community
Stay connected with other developers building on Splunk software.
| devinfo@splunk.com | |
| Issues | https://github.com/splunk/splunk-javascript-logging/issues/ |
| Answers | http://answers.splunk.com/ |
| Blog | http://blogs.splunk.com/dev/ |
| @splunkdev |
Support
The Splunk logging library for JavaScript is community-supported.
- You can find help through our community on Splunk Answers (use the
logging-library-javascripttag to identify your questions). - File issues on GitHub.
Contact us
You can contact support if you have Splunk related questions.
You can reach the Dev Platform team at devinfo@splunk.com.
License
The Splunk Logging Library for JavaScript is licensed under the Apache License 2.0. Details can be found in the LICENSE file.