From 0128aa3a71e33c4f273b681557c24962d4be7d6a Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Thu, 16 May 2024 11:11:23 +0530 Subject: [PATCH] Add Parseable transport --- docs/transports.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/transports.md b/docs/transports.md index 8bb8cc910..2b2b8b1d3 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -51,6 +51,7 @@ there are additional transports written by * [MySQL](#mysql-transport) * [New Relic](#new-relic-agent-transport) * [Papertrail](#papertrail-transport) + * [Parseable](#parseable) * [PostgresQL](#postgresql-transport) * [Pusher](#pusher-transport) * [Sentry](#sentry-transport) @@ -732,6 +733,33 @@ The Papertrail transport connects to a [PapertrailApp log destination](https://p *Metadata:* Logged as a native JSON object to the 'meta' attribute of the item. +### Parseable Transport + +[Parseable](https://parseable.com/) is an open source, general purpose log analytics system. [Parseable-Winston](https://github.com/jybleau/parseable-node-loggers/tree/main/packages/winston#parseable-winston) is a Parseable transport for Winston. + +```js +// Using cjs +const { ParseableTransport } = require('parseable-winston') +const winston = require('winston') + +const parseable = new ParseableTransport({ + url: process.env.PARSEABLE_LOGS_URL, // Ex: 'https://parsable.myserver.local/api/v1/logstream' + username: process.env.PARSEABLE_LOGS_USERNAME, + password: process.env.PARSEABLE_LOGS_PASSWORD, + logstream: process.env.PARSEABLE_LOGS_LOGSTREAM, // The logstream name + tags: { tag1: 'tagValue' } // optional tags to be added with each ingestion +}) + +const logger = winston.createLogger({ + levels: winston.config.syslog.levels, + transports: [parseable], + defaultMeta: { instance: 'app', hostname: 'app1' } +}) + +logger.info('User took the goggles', { userid: 1, user: { name: 'Rainier Wolfcastle' } }) +logger.warning('The goggles do nothing', { userid: 1 }) +``` + ### PostgresQL Transport [@pauleliet/winston-pg-native](https://github.com/petpano/winston-pg-native) is a PostgresQL transport supporting Winston 3.X.