0.0.9 • Published 3 years ago

node-simpletsdb v0.0.9

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

node-simpletsdb

Installation

npm install node-simpletsdb

API

Object: SimpleTSDB

Parameters: options

options has the following properties:

FieldTypeDescription
hoststringThe host used to connect to SimpleTSDB
portnumberThe port used to connect to SimpleTSDB
insertBufferSizenumberoptional: The buffer size used by insertPoints. Defaults to 65536.
Example:
const { SimpleTSDB } = require('node-simpletsdb');

const db = new SimpleTSDB({
  host: '127.0.0.1',
  port: 8981,
});

Object: Point

Parameters: options

options has the following properties:

FieldTypeDescription
metricstringThe metric name of the point
valuenumberThe value of the point
timestampnumberThe timestamp of the point
tagsarrayoptional: The tags associated with the inserted point
Example:
const { Point } = require('node-simpletsdb');

const pt = new Point({
  metric: 'test0',
  value: 99,
  timestamp: Date.now() * 1000000, // SimpleTSDB uses nanoseconds
  tags: {
    'id': '2',
  }
});

Function: insertPoint

Parameters: point
Example:
db.insertPoint(new Point({
  metric: 'test0',
  value: 99,
  tags: {
    'id': '2',
  },
  timestamp: Date.now() * 1000000, // SimpleTSDB uses nanoseconds
}))
  .then(() => console.log('successfully inserted point'))
  .catch(err => console.error(err));

Function: insertPoints

Parameters: points

The same as insertPoint but takes an array of points.

Function: queryPoints

Parameters: query

query has the following properties:

FieldTypeDescription
metricstringThe metric to query.
startnumberThe timestamp in nanoseconds for the start of the query.
endnumberoptional: The timestamp in nanoseconds for the end of the query.
nnumberoptional: The max number of points to return.
tagsobjectoptional: Key/value pairs to add criteria to the query.
windowobjectoptional: Windowing options. See Windowing / Gap filling
aggregatorsarrayoptional: An array of aggregators. See aggregators
Example:
db.queryPoints({
  metric: 'test0',
  start: (Date.now() - 360000) * 1000000, // SimpleTSDB uses nanoseconds
  window: {
    every: '1m',
  }
})
  .then(points => console.log(points))
  .catch(err => console.error(err));

Function: deletePoints

Parameters: options

options has the following properties:

FieldTypeDescription
metricstringThe metric to query.
startnumberThe timestamp in nanoseconds for the start of the query.
endnumberThe timestamp in nanoseconds for the end of the query.
tagsobjectoptional: Key/value pairs to add criteria to the query.
Example:
db.deletePoints({
  metric: 'test0',
  start: (Date.now() - 36000) * 1000000, // SimpleTSDB uses nanoseconds
  end: Date.now() * 1000000
})
  .then(() => console.log('successfully deleted points'))
  .catch(err => console.error(err));

TODO

Add some sort of time library to make working with timestamps easier.

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago