1.1.13 • Published 2 years ago

@autobits/influxdb-client v1.1.13

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
2 years ago

InfluxDB-Client library

Library to send metrics to InfluxDB

To allow javascript developers to send metrics in a easy way without worring about how to connect and how to build the metrics in the influxdb format, also the library has middleware for the developers that use expressjs, this middlewares will generate metrics default metrics that will allow us to collect data about the request like, latency, number of request, error, etc.

How to use it

To use the library you just need to follow the following steps Install the library with npm

npm install @autobits/influxdb-client

Import the library

const influxdb_client = require('@autobits/influxdb-client');

Init client

influxdbClient.init({
    influxdbToken: `9as7XXX==`,
    influxdbOrg: `autobits.XXX`,
    influxdbBucket: `autobits.systems's Bucket`,
    influxdbURL: `https://XXX`,
    appname: `MyAPP`,
    debugMode: true
});

Collect default metrics

// Track server health 
influxdbClient.trackServerHealth();
// Add Middlewares to track API requests 
app.use(influxdbClient.requestMiddleware());
app.use(influxdbClient.errorMiddleware());

Collect custom metrics

fields = [
    { name: 'field1', value: 'OK', datatype: influxdbClient.FIELD_DATA_TYPES.STRING },
    { name: 'field2', value: 1234, datatype: influxdbClient.FIELD_DATA_TYPES.INT },
    { name: 'field3', value: '123.987', datatype: influxdbClient.FIELD_DATA_TYPES.FLOAT },
    { name: 'field4', value: true, datatype: influxdbClient.FIELD_DATA_TYPES.BOOLEAN }
];
tags = [
    { name: 'tag1', value: 'OK' },
    { name: 'tag2', value: 'THIS_IS_FINE' }
];
influxdbClient.writePoint('MyCustomPoint', fields, tags);

Close conection (should be invoked in the SIGTERM, SIGINT, SHUTDOWN handlers)

    // close connection to influx
    await influxdbClient.close();
});

Contributors

The original author and current lead maintainer of this module is the @autobits development team.

License

MIT

1.1.13

2 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago