1.2.0 • Published 8 years ago

sand-influx v1.2.0

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

sand-influx

An InfluxDB sand grain. This module is a wrapper for node-influx.

Installation

npm install sand-influx

Usage

Add influx to your sand config

const sand = require('sand');
const influx = require('influx');

new sand()
    .use(influx)
    .start();

A list of configuration values can be found below

Configuration Options

OptionDescription
usernameusername
passwordpassword
databasedatabase name
hostnamehostname, e.g. 'localhost'
port optionalinflux db port, defult: 8086
requestTimeout optionalnumber of ms to wait before request times out. defaults to 'null' (waits until connection is closed). Use with caution !
maxRetriesoptionalmax number of retries until a request raises an error (e.g 'no hosts available'), default: 2

Functions

writePoint

Writes a point to a series

let point = {value: 100};
sand.influx.writePoint(seriesName, point, options, callback);

writePoints

Write multiple points to a series

let points = [{value: 100}, {value: 200}];
sand.influx.writePoints(seriesName, points, options, callback);

Please note that there's a POST limit at about 2MB per request. Do not submit too many points at once

query

Queries the database, This function manipulates the data that comes back and returns an array of series rows with columns and values mapped automatically.

let query = 'SELECT mean(column) FROM my_series WHERE time > now() - 24h';
sand.influx.query(query, function(err, rows) {
    // Rows should be an array of objects
});

queryRaw

Queries the database using raw influx

let query = 'SELECT mean(column) FROM my_series WHERE time > now() - 24h';
sand.influx.queryRaw(query, callback);
2.0.0-alpha.2

8 years ago

2.0.0-alpha.1

8 years ago

1.2.0

8 years ago

1.1.0

9 years ago

1.0.0

9 years ago