Skip to content
Splunk HTTP Event Collector logging interface for JavaScript
JavaScript
Branch: master
Clone or download
Latest commit 56cccf7 Nov 12, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Change retry example to retry 10 times Dec 9, 2015
test Fix version 0.10.0 release issue Nov 12, 2018
.gitignore Add Travis CI config, make tests compatible with CI Feb 15, 2018
.jshintrc Update jshint config for 4 space indent width May 16, 2017
.npmignore Add .npmignore Sep 15, 2015
.travis.yml Drop support for end of life Node versions Nov 1, 2018
CHANGELOG.md Fix version 0.10.0 release issue Nov 12, 2018
CONTRIBUTING.md Add changelog, contributing notes & license Sep 17, 2015
LICENSE Add changelog, contributing notes & license Sep 17, 2015
README.md Fix version 0.10.0 release issue Nov 12, 2018
index.js Add copyright notices Sep 15, 2015
package-lock.json
package.json Fix version 0.10.0 release issue Nov 12, 2018
splunklogger.js Fix version 0.10.0 release issue Nov 12, 2018
utils.js Fix typo in utils doc comment Nov 19, 2015

README.md

Splunk logging for JavaScript

Version 0.10.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 Enterprise 6.3.0 or later, or Splunk Cloud.
  • An HTTP Event Collector token from your Splunk Enterprise server.

Installation

First, update npm to the latest version by running:

sudo npm install npm -g

Then run:

npm install --save splunk-logging

Usage

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 calling flush().
  • 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.

Email devinfo@splunk.com
Issues https://github.com/splunk/splunk-javascript-logging/issues/
Answers http://answers.splunk.com/
Blog http://blogs.splunk.com/dev/
Twitter @splunkdev

Support

The Splunk logging library for JavaScript is community-supported.

  1. You can find help through our community on Splunk Answers (use the logging-library-javascript tag to identify your questions).
  2. File issues on GitHub.

Contact us

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.

You can’t perform that action at this time.