@danroshko/influxdb-node
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

Influxdb-node

Build Status npm version

Minimal InfluxDB client library for Node.js. Features:

  • execute arbitrary InfluxDB commands using Line Protocol and Query Language
  • buffer writes to InfluxDB
  • optionally transform responses from InfluxDB into more convenient arrays of objects
  • write retires

Installation

npm i @danroshko/influxdb-node

Usage

const Influx = require('@danroshko/influxdb-node');

/* this is the default configuration, all values are optional */
const influx = new Influx({
  db: 'test',
  rp: 'autogen',
  host: '127.0.0.1',
  port: 8086,
  maxBufferSize: 100,
  maxBufferTime: 1000,
  retries: 2,
  retriesInterval: 50
});

influx
  .execute('CREATE DATABASE mydb')
  .then(() => {
    return influx.execute('CREATE RETENTION POLICY one_day ON mydb DURATION 1d REPLICATION 1');
  })
  .then(() => {
    console.log('Database and RP have been created');
  });

/* add point to the internal buffer, it will be
   written to InfluxDB on next buffer flush */
influx.write('cpu,host=server1 value=0.22');

/* write without buffering */
influx.writeImmediate('cpu,host=server1 value=0.22');

influx.query('SELECT "value" FROM test.cpu').then(results => {
  console.log(results);
});

Run tests

sudo docker run -it --rm --network="host" influxdb:1.5.1
npm test

Readme

Keywords

none

Package Sidebar

Install

npm i @danroshko/influxdb-node

Weekly Downloads

0

Version

0.3.3

License

MIT

Unpacked Size

11.9 kB

Total Files

9

Last publish

Collaborators

  • danroshko