A light-weight library to write data to InfluxDB.
- Parse Special Characters
- Inbuilt Retry Mechanisms
const influx = require('influxdb-lite');
await influx.write(
{
url: 'http://influx.url',
db: 'database name'
},
[
{
measurement: 'web',
fields: {
load: 12.34
}
},
{
measurement: 'web',
fields: {
load: 5.4
},
tags: {
host: 'linux'
},
timestamp: Date.now()
}
]
);
// or
const db = influx.db({ url: 'http://influx.url', db: 'database name'});
await db.write({
measurement: 'web',
fields: {
load: 12.34
}
});
// query
const db = influx.db({ url: 'http://influx.url', db: 'database name', username: 'user', password: 'pass' });
await db.query('SELECT * FROM measurement');
await db.flux('from(bucket:"telegraf")');
const influx = require('influxdb-lite');
await influx.write(
{
url: 'http://influx.url',
version: 'v2',
bucket: 'bucket name',
org: 'org',
token: 'token',
},
[
{
measurement: 'web',
fields: {
load: 12.34
}
},
{
measurement: 'web',
fields: {
load: 5.4
},
tags: {
host: 'linux'
},
timestamp: Date.now()
}
]
);
npx influxdb-lite insert --url <influx-base-url> --username <user> --password <pass> --db <database> --measurement <measurement> --tags "key=value" --fields "key=value" --ts <timestamp>
Inspired from influxdb-v2