A InfluxDB transport for winston.
tldr;?
: To break the winston codebase into small modules that work
together.
The winston codebase has been growing significantly with contributions and other logging transports. This is awesome. However, taking a ton of additional dependencies just to do something simple like logging to the Console and a File is overkill.
var winston = require('winston');
/**
* Requiring `winston-influxdb` will expose
* `winston.transports.InfluxDB`
*/
require('winston-influxdb').InfluxDB;
winston.add(winston.transports.InfluxDB, options);
Caution: InfluxDB purpose is not properly to store logs but values and tags, then, with default configuration, message is not used by this transport. only meta.tags and meta.values are used.
You can change InfluxDB transport comportment by providing buildValues and buildTags options at transport startup.
The InfluxDB transport takes the following options. 'db' is required:
- level: Level of messages that this transport should log, defaults to 'info'.
- db: InfluxDB database name.
- hosts: InfluxDB hosts array default: [{ host: 'localhost', port: 8086, protocol: 'http' }]
- measurement: The name of the measurement you want to store log messages in, defaults to 'log'.
- username: The username to use when logging into InfluxDB.
- password: The password to use when logging into InfluxDB. If you don't supply a username and password it will not use InfluxDB authentication.
- name: Transport instance identifier. Useful if you need to create multiple InfluxDB transports.
- buildValues: a function (level, message, meta, callback) used to build values objects, default function use meta.values
- buildTags: a function (level, message, meta, callback) used to build tags objects, default function use meta.tags
$ npm install winston
$ npm install winston-influxdb