# @autobits/influxdb-client

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

Latest version **1.1.13** (published 2021-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @autobits/influxdb-client
pnpm add @autobits/influxdb-client
yarn add @autobits/influxdb-client
bun add @autobits/influxdb-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.13 |
| Published | 2021-11-20 |
| First published | 2020-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | autobits |
| Maintainers | awilches |
| Keywords | influxdb, metrics, autobits |

## Links

- npm: https://www.npmjs.com/package/@autobits/influxdb-client
- Repository: https://bitbucket.org/autobotsteam/influxdb-client
- Homepage: https://bitbucket.org/autobotsteam/influxdb-client/src/master/README.md
- Issues: https://bitbucket.org/autobotsteam/influxdb-client/issues
- npm.io page: https://npm.io/package/@autobits/influxdb-client

## Dependencies (2)

- [node-os-utils](https://npm.io/package/node-os-utils.md) 1.3.2
- [@influxdata/influxdb-client](https://npm.io/package/@influxdata/influxdb-client.md) 1.8.0

## Recent versions

- 1.1.13 (latest) — 2021-11-20
- 1.1.12 — 2020-11-05
- 1.1.11 — 2020-11-05
- 1.1.10 — 2020-11-05
- 1.1.9 — 2020-11-04
- 1.1.8 — 2020-11-04
- 1.1.7 — 2020-11-04
- 1.1.6 — 2020-11-03
- 1.1.5 — 2020-11-03
- 1.1.4 — 2020-11-03
- 1.1.3 — 2020-11-03
- 1.1.2 — 2020-11-03
- 1.1.1 — 2020-11-03
- 1.1.0 — 2020-11-03
- 1.0.0 — 2020-11-03

## README

# 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

```js
npm install @autobits/influxdb-client
```

Import the library

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

Init client

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

Collect default metrics

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

Collect custom metrics

```js
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)

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

## Contributors

The original author and current lead maintainer of this module is the [@autobits development team](https://autobits.com.co).

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/@autobits/influxdb-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
