# winston-splunk-http

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

Latest version **2.2.1** (published 2018-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install winston-splunk-http
pnpm add winston-splunk-http
yarn add winston-splunk-http
bun add winston-splunk-http
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2018-10-24 |
| First published | 2018-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Adrian Hall |
| Maintainers | markelog |
| Keywords | splunk, winston, tools, logging |

## Links

- npm: https://www.npmjs.com/package/winston-splunk-http
- Repository: https://github.com/markelog/winston-splunk-http
- Issues: https://github.com/markelog/winston-splunk-http/issues
- npm.io page: https://npm.io/package/winston-splunk-http

## Dependencies (3)

- [util](https://npm.io/package/util.md) ^0.10.3
- [winston](https://npm.io/package/winston.md) ^2.1.1
- [splunk-logging](https://npm.io/package/splunk-logging.md) ^0.9.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.2.1 (latest) — 2018-10-24
- 2.2.0 — 2018-10-24
- 2.1.0 — 2018-10-24
- 2.0.0 — 2018-10-24

## README

# winston-splunk-httplogger

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

  [![Depedency Status](https://david-dm.org/adrianhall/winston-splunk-httplogger.svg)](https://david-dm.org/adrianhall/winston-splunk-httplogger)
  [![devDependency Status](https://david-dm.org/adrianhall/winston-splunk-httplogger/dev-status.svg)](https://david-dm.org/adrianhall/winston-splunk-httplogger?type=dev)

## Installation

```sh
npm install --save winston winston-splunk-httplogger
```

## Usage

```javascript
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:

 * **config:** configuration settings for the `Splunk` 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.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

## Configuring Splunk

  1. Log into your Splunk instance as an Administrator
  2. Go to Settings &gt; 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

  * [HTTP Event Collector]
  * [Splunk logging for JavaScript]

[Winston]: https://github.com/winstonjs/winston
[Splunk]: http://www.splunk.com
[HTTP Event Collector]: http://dev.splunk.com/view/event-collector/SP-CAAAE6M
[Splunk logging for JavaScript]: https://github.com/splunk/splunk-javascript-logging

---
_Source: https://npm.io/package/winston-splunk-http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
