Skip to content

splunk/splunk-javascript-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

fa7f3b6 · Nov 3, 2015

History

91 Commits
Oct 9, 2015
Nov 3, 2015
Sep 11, 2015
Sep 11, 2015
Sep 15, 2015
Sep 17, 2015
Sep 17, 2015
Sep 17, 2015
Oct 9, 2015
Sep 15, 2015
Sep 17, 2015
Nov 3, 2015
Oct 28, 2015

Repository files navigation

Splunk Logging Library for JavaScript (beta)

Version 0.8.0

This project provides a simple interface for logging to Splunk's Event Collector.

Requirements

  • Splunk 6.3+.
  • An HTTP Event Collector token from your Splunk server.
  • Node.js v0.10+.

Installation

If you already have Node.js and npm installed, simply run: npm install --save splunk-logging.

Usage

See the examples folder for more examples:

  • basic.js: shows how to configure a logger and send a log message to Splunk.
  • batching.js: shows how to queue log messages, and send them in batches.
  • middleware.js: shows how to add an express-like middleware function to be called before sending log messages to Splunk.
  • retry.js: shows how to configure retries on errors.

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.

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

Contact us

You can reach the Developer 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.