# logstash-client

> General logstash client with multiple transport support

Latest version **1.1.1** (published 2016-09-29) · MIT license · 4.5K weekly downloads

## Install

```sh
npm install logstash-client
pnpm add logstash-client
yarn add logstash-client
bun add logstash-client
```

## Health

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

Positive: no vulnerabilities.

Warnings: no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-09-29 |
| First published | 2014-08-24 |
| Weekly downloads | 4.5K |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Purpose Industries |
| Maintainers | lennon, oroce, ruffle1986 |
| Keywords | logstash, logging, amqp |

## Links

- npm: https://www.npmjs.com/package/logstash-client
- Repository: https://github.com/purposeindustries/node-logstash-client
- Issues: https://github.com/purposeindustries/node-logstash-client/issues
- npm.io page: https://npm.io/package/logstash-client

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [reconnect-net](https://npm.io/package/reconnect-net.md) 0.0.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
- [@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
- [ton-logger](https://npm.io/package/ton-logger.md) — 457 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-09-29
- 1.1.0 — 2016-07-04
- 1.0.2 — 2016-06-09
- 1.0.1 — 2016-04-22
- 1.0.0 — 2014-08-24

## README

# logstash-client [![Build Status](https://travis-ci.org/purposeindustries/node-logstash-client.svg)](https://travis-ci.org/purposeindustries/node-logstash-client) [![Coverage Status](https://coveralls.io/repos/purposeindustries/node-logstash-client/badge.png)](https://coveralls.io/r/purposeindustries/node-logstash-client)

General purpose logstash with multiple transport support

## Features

* tcp uses [juliangruber](https://github.com/juliangruber)'s [reconnect-net](https://github.com/juliangruber/reconnect-net) for handling reconnection
* logging library independent (there are some logstash clients for winston, bunyan etc)

## TODOS

* [x] TCP Transport
* [x] UDP Transport
* [x] Memory Transport (for testing)
* [ ] AMQP Transport
* [ ] Codec support

## Example

```js
var Logstash = require('logstash-client');

var logstash = new Logstash({
  type: 'udp', // udp, tcp, memory
  host: 'logstash.example.org',
  port: 13333
});
logstash.send(message [, callback]);
```

## API

### Constructor

Takes the following parameters:
* **type**: type of connection, currently supported tcp, udp, memory
* **host**: remote hostname
* **port**: remote port
* **format** (optional): formatter function (by default the message gets JSON.stringified)
* **maxQueueSize** (optional): Restricts the amount of messages queued when there is no connection. If not specified the queue is not limited in size.

Example:

```js
new Client({
  type: 'tcp',
  host: 'logstash.example.org',
  port: 8099,
  format: function(message) {
    message.formattedAt = new Date();
    message.password = '!FILTERED!';
    return JSON.stringify(message, null, 2);
  },
  maxQueueSize: 1000
});
```

### Client#send

Takes the following parameters:

* **message**: an object what you are trying to send to your logstash instance
* **callback** (optional): a function called when the message has been sent

Example:

```js
var client = new Client({
  type: 'tcp',
  host: 'example.org',
  port: 1337
});
client.send({
  '@timestamp': new Date(),
  'message': 'Important',
  'level': 'error'
});
```

## License

MIT

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