InfluxDB stats collector for node.js
For InfluxDB 0.9.x use version 1.x.x of this module.
For InfluxDB <= 0.8.x use version 0.x.x of this module.
Note that the API changed between 0.x and 1.x to move the series name into the constructor.
// set some env var (i.e INFLUX_STATS_URI)// ;var Stats = ;// create a stats collectorvar mem_stats = ;// example stat collection of process memory usage;// make sure to handle errors to avoid uncaughtException// would be annoying if stats crashed your app :)mem_stats;
influx-collector is configured via the URI string. The following options can be set by specifying them as query parameters in the URI
|flushInterval||5000||Stats are flushed every flushInterval milliseconds.|
|instantFlush||no||Flush stats to server on collection.|
|time_precision||Time precision when writing data. Only relevant if you are specifying the
Flushing and Batches
By default, stats are flushed in batches every
flushInterval milliseconds. This allows for many stats to be collected and flushed at once. You can override these behaviors via the
autoFlush and interval options as query parameters. You can also turn on
instantFlush which will send the stats to InfluxDB as soon as they are collected (every collect call will be an http request). I do not recommend this approach for high frequency stats.
Example of a 10 second flush interval
To manually flush the stats at any time (or if autoFlush is off), use the
.flush method on your stats instance.
- Make sure to attach and
errorhandler so stats don't crash your entire app.
- Useful to log pid and app names/tags for generic stats so you can
- Grafana is amazing.