npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mondomob/winston-splunk-httplogger

v2.4.0

Published

A Winston compatible transport for logging to a Splunk HTTP Event Collector

Downloads

4

Readme

winston-splunk-httplogger

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

Depedency Status devDependency Status

Compatibility

Winston >= 3.0.0 is required for winston-splunk-httplogger >= 2.0.0. Please use version 1.2.2 for legacy Winston support.

Installation

npm install --save winston winston-splunk-httplogger

Usage

var winston = require('winston'),
    SplunkStreamEvent = require('winston-splunk-httplogger');

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 SplunkStreamEvent({ splunk: splunkSettings })
    ]
});

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

API

splunkTransport = new SplunkStreamEvent(config);

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

  • config: configuration settings for the SplunkStreamEvent instance
  • config.splunk: the Splunk Logger settings
  • config.splunk.token: the Splunk HTTP Event Collector token
  • [config.level=info]: logging level to use, will show up as the severity field of an event
  • [config.splunk.index=winston-index]: the index for the events sent to Splunk
  • [config.splunk.source=winston]: the source for the events sent to Splunk
  • [config.splunk.sourcetype=winston-splunk-logger]: the sourcetype for the events sent to Splunk
  • [config.splunk.host=localhost]: the Splunk HTTP Event Collector host
  • [config.splunk.maxRetries=0]: how many times to retry the splunk logger
  • [config.splunk.port=8088]: the Splunk HTTP Event Collector port
  • [config.splunk.path=/services/collector/event/1.0]: URL path to use
  • [config.splunk.protocol=https]: the protocol to use
  • [config.splunk.url]: URL string to pass to url.parse. This will try to set host, path, protocol, port, url. Any of these values will be overwritten if the corresponding property is set on config
  • [config.splunk.eventFormatter]: formats events, returning an event as a string, function(message, severity)
  • [config.batchInterval=0]: automatically flush events after this many milliseconds. When set to a non-positive value, events will be sent one by one. This setting is ignored when non-positive
  • [config.maxBatchSize=0]: automatically flush events after the size of queued events exceeds this many bytes. This setting is ignored when non-positive
  • [config.maxBatchCount=1]: automatically flush events after this many events have been queued. Defaults to flush immediately on sending an event. This setting is ignored when non-positive
  • [config.exitOnError=true]: whether an unexpected request error causes the javascript process to exit. Defaults to true.

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 SplunkStreamEvent() object. In the example above, this is done by placing the token in the SPLUNK_TOKEN environment variable.

See Also