create a new event
the title of the event
the body of the event
an optional object continaing any of the following additional optional properties
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var title = "some new event";
var text = "IT HAPPENED!";
dogapi.event.create(title, text, function(err, res){
console.dir(res);
});
title = "another event";
text = "IT HAPPENED AGAIN!";
var properties = {
tags: ["some:tag"],
alert_type: "error"
};
dogapi.event.create(title, text, properties, function(err, res){
console.dir(res);
});
get event details from the provided event id
the id of the event to fetch
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.event.get(10005, function(err, res){
console.dir(res);
});
query the event stream
POSIX timestamp for start of query
POSIX timestamp for end of query
optional parameters to use for the query
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var now = parseInt(new Date().getTime() / 1000);
var then = now - 3600; // an hour ago
var parameters = {
tags: "some:tag",
sources: "jenkins"
};
dogapi.event.query(then, now, parameters, function(err, res){
console.dir(res);
});
submit a new metric
the metric name
single datapoint or array of [timestamp, datapoint], if a single point is given "now" is used as the timestamp
optional, object which can contain the following keys
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.metric.send("my.metric", 1000, function(err, results){
console.dir(results);
});
var now = parseInt(new Date().getTime() / 1000);
dogapi.metric.send("my.metric", [now, 1000], function(err, results){
console.dir(results);
});
send a list of metrics
an array of metrics where each element is an object with the following keys
dogapi.metric.send)function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var now = parseInt(new Date().getTime() / 1000);
var metrics = [
{
metric: "my.metric",
points: [now, 1000],
tags: ["tag:value"]
},
{
metric: "another.metric",
points: 1000
}
];
dogapi.metric.send_all(metrics, function(err, results){
console.dir(results);
});
make a metric query
POSIX timestamp for start of query
POSIX timestamp for end of query
the string query to perform (e.g. "system.cpu.idle{*}by{host}")
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var now = parseInt(new Date().getTime() / 1000);
var then = now - 3600; // one hour ago
var query = "system.cpu.idle{*}by{host}";
dogapi.metric.query(then, now, query, function(err, res){
console.dir(res);
});
get all host tags
optional, only show tags for a particular source [default: null]
function callback(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.tag.get_all(function(err, results){
console.dir(results);
});
get the host tags for a provided host name or host id
the hostname or host id
optional, an object of options for the query allowing the following
function callback(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.tag.get("host.name", function(err, results){
console.dir(results);
});
assign new host tags to the provided host name or host id
the hostname or host id
list of <tag>:<value> tags to assign to the server
optional, the source of the tags (e.g. chef, puppet, etc) [default: users]
function callback(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.tag.create("host.name", ["role:webserver"], function(err, results){
console.dir(results);
});
update the host tags for the provided host name or host id
the hostname or host id
list of <tag>:<value> tags to assign to the server
optional, the source of the tags (e.g. chef, puppet, etc) [default: users]
function callback(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.tag.update("host.name", function(err, results){
console.dir(results);
});
delete the host tags for the provided host name or host id
the hostname or host id
optional, the source of the tags (e.g. chef, puppet, etc) [default: users]
function callback(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.tag.delete("host.name", function(err, results){
console.dir(results);
});
used to make a raw request to the datadog api
http method GET, POST, PUT, DELETE
the api url path e.g. /tags/hosts
an object which allows the keys query or body
function to call on success/failure callback(err, result)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.client.request("GET", "/url/path", {}, function(err, results){
console.dir(results);
});
An object which allows you to override the default set parameters for interacting with the datadog api. The available options are.
v1]api.datadoghq.com]var dogapi = require("dogapi");
var options = {
api_key: "<API_KEY_HERE>",
app_key: "<APP_KEY_HERE>"
};
dogapi.initialize(options);
dogapi.event.create(...);
