https://github.com/peakwinter/express-influxdb-logger
Express logging middleware for InfluxDB syslog
https://github.com/peakwinter/express-influxdb-logger
Last synced: 10 months ago
JSON representation
Express logging middleware for InfluxDB syslog
- Host: GitHub
- URL: https://github.com/peakwinter/express-influxdb-logger
- Owner: peakwinter
- License: mit
- Created: 2019-05-12T16:14:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-12T21:49:19.000Z (about 7 years ago)
- Last Synced: 2025-01-30T03:48:20.771Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-influxdb-logger
express-influxdb-logger is an [Express middleware](https://expressjs.com/en/guide/using-middleware.html) that can be used to log info on all HTTP requests to an InfluxDB instance in syslog format.
## Getting Started
```js
const express = require('express');
const createInfluxDBLogger = require('express-influxdb-logger');
const app = express();
app.use(createInfluxDBLogger({
host: 'my-influxdb-server.host',
port: 8086,
database: 'database_name',
username: 'influxdb_user',
password: 'influxdb_password,
}));
// Then declare your route handlers below.
```
## Configuration
The following options are accepted when creating an instance of the InfluxDB logger:
* `host`: hostname of your InfluxDB server _(required)_
* `port`: port on which the InfluxDB's HTTP server listens on _(required)_
* `database`: name of the database to log to _(required)_
* `protocol`: either 'http' or 'https' _(required, default: `https`)_
* `username`: username to authenticate with if the server requires
* `password`: password to authenticate with if the server requires
* `flushAfter`: send log lines to the database in batches of this number _(default: 5)_
* `flushInterval`: send log lines to the database after this number of milliseconds max _(default: 10000)_
* `measurement`: custom InfluxDB measurement name to use _(default: `syslog`)_
* `appname`: application name to be provided in the syslog lines _(default: `express`)_
* `facility`: syslog facility name to use _(default: `local0`)_
* `client`: an instance of an `Influx.InfluxDB` connection to use rather than create a new one
* `requestOptions`: an object of options passed directly to `https.request` when logging
Note the `flushAfter` and `flushInterval` config values work together. By default, a batch will be sent to the server every time it has least 5 log entries in it, OR after 10 seconds of staleness at the longest.
## Credits
A TypeScript fork and extension of [influx-express](https://github.com/jackzampolin/influx-express).