2.2.1 • Published 6 years ago

winston-splunk-http v2.2.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

winston-splunk-httplogger

A Winston transport for logging to Splunk with a HTTP Event Collector.

Depedency Status devDependency Status

Installation

npm install --save winston winston-splunk-httplogger

Usage

var winston = require('winston'),
    Splunk = require('winston-splunk-http');

var splunkSettings = {
    token: process.env.SPLUNK_TOKEN,
    host: process.env.SPLUNK_HOST || 'localhost'
};

// Now use winston as normal
var logger = new winston.Logger({
    transports: [
        new winston.transports.Console(),
        new Splunk({ splunk: splunkSettings })
    ]
});

logger.info('This is sent to Splunk');

API

splunkTransport = new Splunk(config);

Create a new instance of Splunk. Takes the following configuration:

Configuring Splunk

  1. Log into your Splunk instance as an Administrator
  2. Go to Settings > Data Inputs
  3. Click on HTTP Event Collector under Local inputs
  4. Click on New Token
  5. Walk through the wizard to configure your new HTTP Event Collector

Splunk will provide you with a token at the end of the wizard. You need to insert that token into the splunk object you use to create the Splunk() object. In the example above, this is done by placing the token in the SPLUNK_TOKEN environment variable.

See Also