New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@autobits/influxdb-client

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autobits/influxdb-client

This module provide and usefull client to ship structured data to influxDB v2.0

  • 1.1.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 20 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc