Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including inlean with all npm packages installed. Try it out:

var inlean = require("inlean")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

inlean v1.0.0

Lean influxdb stats collector

inlean

Build Status Coverage Status

Lean influxdb stats collector

Install

$ npm install --save inlean

Test

$ npm test

Usage

var Inlean = require('inlean')
var client = new Inlean({
  host: 'http://127.0.0.1:8086'
, db: 'biscuits'
, tags: {
    service: 'db'
  }
})

Client(opts)

opts must be an object and can have the following properties:

  • host the influx db host (ex. http://localhost:8086) [required]
  • db the database name [optional]
  • tags an object containing the tags to be used for every request [optional]

Note: the db is not automatically created. Use Client#createDb to create

Client#setDb(name)

sets the current database

Client#createDb(name, cb)

creates a database with the given name

Client#writeFloat(opts, cb)

opts must be an object and can have the following properties:

  • name the metric name [required]
  • val the value [required]
  • tags an object containing the tags to apply [optional]
  • ts a timestamp [optional]

Client#writeInt(opts, cb)

opts must be an object and can have the following properties:

  • name the metric name [required]
  • val the value [required]
  • tags an object containing the tags to apply [optional]
  • ts a timestamp [optional]

Client#writeBool(opts, cb)

opts must be an object and can have the following properties:

  • name the metric name [required]
  • key the key to write (defaults to value) [optional]
  • val the value [required]
    • true and false will be correctly serialized
  • tags an object containing the tags to apply [optional]
  • ts a timestamp [optional]

Client#writeString(opts, cb)

opts must be an object and can have the following properties:

  • name the metric name [required]
  • key the key to write (defaults to value) [optional]
  • val the value [required]
  • tags an object containing the tags to apply [optional]
  • ts a timestamp [optional]

TODO

  • only send in batches to limit http activity

Author

Evan Lucas

License

MIT (See LICENSE for more info)

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free