logzio-nodejs-metrics
Version:
A nodejs implementation for sending metrics to Logz.io
54 lines (38 loc) • 2.43 kB
Markdown

# logzio-nodejs-metrics
NodeJS metrics shipper for Logz.io.
Based on the [logzio-nodejs](https://github.com/logzio/logzio-nodejs-metrics) logger, it will send metrics to your Logz.io metrics account.
## Sample usage
```javascript
var metricsShipper = require('logzio-nodejs-metrics').createMetrics({
token: '__YOUR_API_TOKEN__',
});
// sending metrics with send(metrics, dimensions)
metricsShipper.send(
{ cpu: 0.2, memory: 200 },
{ host: 'my-host', env: 'PROD' },
);
```
**Note:** If logzio-js is used as part of a serverless service (AWS Lambda, Azure Functions, Google Cloud Functions, etc.), add `logger.sendAndClose()` at the end of the run.
## Options
* **token**
Mandatory. Your API logging token. Look it up in the Device Config tab in Logz.io
* **type** - Log type. Help classify logs into different classifications
* **protocol** - `http`, `https` or `udp`. Default: `http`
* **host** - Destination host name. Default: `listener.logz.io`
* **port** - Destination port. Default port depends on protocol. `http` is `8070` and `8071` is for `https`
* **sendIntervalMs** - Time in milliseconds to wait between retry attempts. Default: `2000` (2 sec)
* **bufferSize** - The maximum number of messages the logger will accumulate before sending them all as a bulk. Default: `100`.
* **numberOfRetries** - The maximum number of retry attempts. Default: `3`
* **debug** - Should the logger print debug messages to the console? Default: `false`
* **callback** - A callback function called when an unrecoverable error has occured in the logger. The function API is: function(err) - err being the Error object.
* **timeout** - The read/write/connection timeout in milliseconds.
* **addTimestampWithNanoSecs** - Add a timestamp with nano seconds granularity. This is needed when many logs are sent in the same millisecond, so you can properly order the logs in kibana. The added timestamp field will be `@timestamp_nano` Default: `false`
* **compress** - If true the the logs are compressed in gzip format. Default: `false`
* **internalLogger** - set internal logger that supports the function log. Default: console.
## Update log
**1.0.0**
- Ship metrics based on [logzio-nodejs](https://github.com/logzio/logzio-nodejs-metrics)
# Scripts
- run `npm install` to install required dependencies
- run `npm test` to run unit tests