Coder Social home page Coder Social logo

node-dogapi's Introduction

dogapi

npm version Build Status Dependency Status

Datadog API Node.JS Client.

Official Datadog API Documentation: http://docs.datadoghq.com/api/

dogapi API Docs: http://brettlangdon.github.io/node-dogapi/

StatsD

dogapi does not provide any functionality to talk to a local dogstatsd server. This library is purely an interface to the HTTP api.

If you are looking for a good Datadog StatsD library, I recommend checking out node-dogstatsd.

Installation

From NPM:

[sudo] npm install dogapi

From source:

git clone git://github.com/brettlangdon/node-dogapi.git
cd ./node-dogapi
npm install

Configuration

You will need your Datadog api key as well as an application key to use dogapi.

Keys can be found at: https://app.datadoghq.com/account/settings#api

var dogapi = require("dogapi");

var options = {
 api_key: "YOUR_KEY_HERE",
 app_key: "YOUR_KEY_HERE",
};

dogapi.initialize(options);

HTTPS Proxy

If you are behind a proxy you need to a proxy agent. You can use the https proxy agent from http://blog.vanamco.com/proxy-requests-in-node-js/ if you like. To configure dogapi with the agent just add it to the options.

var dogapi = require("dogapi");

//Code from http://blog.vanamco.com/proxy-requests-in-node-js/
var HttpsProxyAgent = require("./httpsproxyagent");

var agent = new HttpsProxyAgent({
   proxyHost: "MY_PROXY_HOST",
   proxyPort: 3128
});

var options = {
   api_key: "YOUR_KEY_HERE",
   app_key: "YOUR_KEY_HERE",
   proxy_agent: agent
};

dogapi.initialize(options);

CLI Usage

dogapi now ships with a command line interface dogapi. To use it you will need a .dogapirc file which meets the standards of https://github.com/dominictarr/rc

The config file must contain both api_key and app_key keys (you can find your datadog api and app keys here https://app.datadoghq.com/account/settings#api)

Example:

{
  "api_key": "<API_KEY>",
  "app_key": "<APP_KEY>"
}

Usage

Please run dogapi --help to see current usage documentation for the tool.

Every api method available in dogapi is exposed via the cli tool.

Major changes from 1.x.x to 2.x.x

We have updated major versions for this library due to a backwards incompatible change to the argument format for dogapi.metric.send and dogapi.metric.send_all.

dogapi.metric.send

Previously in 1.x.x:

var now = parseInt(new Date().getTime() / 1000);
dogapi.metric.send("metric.name", 50);
dogapi.metric.send("metric.name", [now, 50]);

Now in 2.x.x:

var now = parseInt(new Date().getTime() / 1000);
dogapi.metric.send("metric.name", 50);
dogapi.metric.send("metric.name", [50, 100]);
dogapi.metric.send("metric.name", [[now, 50]]);

dogapi.metric.send_all

Previously in 1.x.x:

var now = parseInt(new Date().getTime() / 1000);
var metrics = [
  {
    metric: "metric.name",
    points: [now, 50]
  },
  {
    metric: "metric.name",
    points: 50
  }
];
dogapi.metric.send_all(metrics);

Now in 2.x.x:

var now = parseInt(new Date().getTime() / 1000);
var metrics = [
  {
    metric: "metric.name",
    points: [[now, 50]]
  },
  {
    metric: "metric.name",
    points: [50, 100]
  },
  {
    metric: "metric.name",
    points: 50
  }
];
dogapi.metric.send_all(metrics);

License

The MIT License (MIT) Copyright (c) 2013 Brett Langdon [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-dogapi's People

Contributors

brettlangdon avatar alexcreek avatar dalehamel avatar mousavian avatar jkurz avatar jupemara avatar tdlsheriff avatar crrobinson14 avatar jetmind avatar jrgm avatar mklopets avatar reason-bv avatar robertprediger avatar rscheuermann avatar vijayparikh avatar

Watchers

James Cloos avatar Hao avatar

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.