GithubHelp home page GithubHelp logo

kairosdb's Introduction

KairosDB Build Status Coverage Status

####A node.js KairosDB client

This is a complete KairosDB client for node.js, it supports all KairosDB commands.

Install

$ npm install kairosdb

Usage

Simple example:

var 
  kdb = require('kairosdb'),
  client = kdb.init();

client.version(function(err, version){
  console.log(version);
});

This will display:

{
  "version": "KairosDB 0.9.3.20140127084223"
}

Pushing data points:

var 
  kdb = require('kairosdb'),
  client = kdb.init();

  var data = [
    {
      "name": "metricname",
      "timestamp": new Date().getTime(),
      "value": 321,
      "tags": {
        "host": "server"
      }
    }
  ];

  client.datapoints(data, function (err, result) {
    if (err)
      throw err;
  });

Sending Commands

Each KairosDB command is exposed as a function on the client object. All functions take an arguments object which are passed as the request body to KairosDB and a callback function. The callback function receives an err argument (null if none) and a results argument containing the server result (if any). Here is an example of passing arguments and a callback:

  var data = [
    {
      "name": "metricname",
      "timestamp": new Date().getTime(),
      "value": 321,
      "tags": {
        "host": "server"
      }
    }
  ];

  client.datapoints(data, function (err, result) {
    if (err)
      throw err;
  });

Minimal parsing is done on the replies. The library will try to JSON.parse the result string and pass it to the callback function.

API

kairosdb.init(host, port, options)

Create a new client connection. host default to localhost and port defaults to 8080. If you have redis-server running on the same computer as node, then the defaults for port and host are probably fine.
options is an object with the following possible properties:

  • debug: enable print out to console of debug information.

Contributing

I'd would love to get your help and have outlined a simple Contribution Policy to support a transparent and easy merging of ideas, code, bug fixes and features. If you're looking for a place to start, you can always go over the list of open issues, pick one and get started. If you're feeling lost or unsure, just let me know.

###License Copyright (c) 2014 Itay Weinberger. MIT Licensed, see LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.