Skip to content

test-results-reporter/influxdb-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

influxdb-lite

A light-weight library to write data to InfluxDB.

  • Parse Special Characters
  • Inbuilt Retry Mechanisms

Example

Influx DB v1

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")');

Influx DB v2

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()
      }
    ]
  );

CLI

Insert Data

npx influxdb-lite insert --url <influx-base-url> --username <user> --password <pass> --db <database> --measurement <measurement> --tags "key=value" --fields "key=value" --ts <timestamp>

Note

Inspired from influxdb-v2

About

A light-weight library to write and read data from InfluxDB.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published