splunk / splunk-javascript-logging

Splunk HTTP Event Collector logging interface for JavaScript
http://dev.splunk.com/view/splunk-logging-javascript/SP-CAAAE63
Apache License 2.0
85 stars 48 forks source link

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

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:

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

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.

License

The Splunk Logging Library for JavaScript is licensed under the Apache License 2.0. Details can be found in the LICENSE file.