create a new comment
the message of the comment
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.comment.create("a comment message", function(err, res){
console.dir(res);
});
update an existing comment
the id of the comment to update
the message of the comment
optional, the handle to associate the comment with (e.g. "user@domain.com")
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.comment.update(1234, "new message", function(err, res){
console.dir(res);
});
remove a comment
the id of the comment to remove
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.comment.remove(1234, function(err, res){
console.dir(res);
});
schedule a new downtime
string scope that the downtime should apply to (e.g. "env:staging")
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.downtime.create("env:staging", function(err, res){
console.dir(res);
});
update an existing downtime
the id the downtie to update
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var properties = {
scope: "env:staging"
};
dogapi.downtime.update(1234, properties, function(err, res){
console.dir(res);
});
delete a scheduled downtime
the id of the downtime
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.downtime.remove(1234, function(err, res){
console.dir(res);
});
get a scheduled downtimes details
the id of the downtime
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.downtime.get(1234, function(err, res){
console.dir(res);
});
get all downtimes details
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.downtime.getAll(function(err, res){
console.dir(res);
});
create an embed graph of a metric query
The request array to pass create in the embed
optional, object of extra parameters to pass to the embed create (see options[*] params)
optional, one of ("1_hour", "4_hours", "1_day", "2_days", and "1_week")
optional, one of ("small", "medium", "large", "xlarge")
optional, "yes" or "no"
optional, the title of the embed
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var query = "system.cpu.idle{*}";
var graphJSON = {
viz: "timeseries",
requests: [
{
q: query,
aggregator: "avg",
conditional_formats: [],
type: "area"
}
]
}
var options = {
timeframe: "1_hour",
size: "xlarge",
legend: "yes",
title: "my awesome embed"
};
dogapi.embed.create(graphJSON, options, function(err, res){
console.dir(res);
});
delete an embed with a specific id
the id of the embed to delete
function(err, res)
var embedid = "foo";
dogapi.embed.revoke(embedid, function(err, res){
console.dir(res);
});
get all embeds from datadog
function(err, res)
dogapi.embed.getAll(function(err, res){
console.dir(res);
});
get a single embed
the id of the embed to get
function(err, res)
var embedId = "foo";
dogapi.embed.get(embedId, function(err, res){
console.dir(res);
});
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);
});
take a snapshot of a metric query
the metric query to use for the snapshot
POSIX timestamp for the beginning of the query
POSIX timestamp for the end of the query
optional, an event query to overlay event bands on the snapshot
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var query = "system.cpu.idle{*}";
var to = dogapi.now();
var from = to - 3600; // an hour ago
dogapi.graph.snapshot(query, from, to, function(err, res){
console.dir(res);
});
mute the given host, if it is not already muted
the hostname of the host to mute
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.host.mute("my.host.name", function(err, res){
console.dir(res);
});
unmute the given host, if it is not already unmuted
the hostname of the host to unmute
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.host.unmute("my.host.name", function(err, res){
console.dir(res);
});
search for metrics or hosts
the query to use for search see datadog docs for examples of the query (e.g. "hosts:database", "metrics:system" or "test")
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.infrastructure.search("hosts:database", function(err, res){
console.dir(res);
});
submit a new metric
the metric name
a single data point (e.g. 50
), an array of data points (e.g. [50, 100]
)
or an array of [timestamp, value]
elements (e.g. [[now, 50], [now, 100]]
)
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);
});
dogapi.metric.send("my.metric", [500, 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);
});
dogapi.metric.send("my.counter", 5, {type: "count"}, 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
50
), an array of data points (e.g. [50, 100]
) or an array of [timestamp, value]
elements (e.g. [[now, 50], [now, 100]]
)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: [50, 1000]
},
{
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);
});
create a new monitor
one of "metric alert" or "service check"
the monitor query to use, you probably want to read datadog's monitor create docs
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var metricType = "metric alert";
var query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100";
dogapi.monitor.create(metricType, query, function(err, res){
console.dir(res);
});
get an existing monitor's details
the id of the monitor
an array containing any of the following "all", "alert", "warn", or "no data"
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.get(1234, function(err, res){
console.dir(res);
});
get all monitors
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.getAll(function(err, res){
console.dir(res);
});
update a monitor's details
the id of the monitor to edit
the query that the monitor should have, see the monitor create docs for more info
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100";
dogapi.monitor.update(1234, query, function(err, res){
console.dir(res);
});
delete an existing monitor
the id of the monitor to remove
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.remove(1234, function(err, res){
console.dir(res);
});
mute an existing monitor
the id of the monitor to mute
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.mute(1234, function(err, res){
console.dir(res);
});
mute all monitors
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.muteAll(function(err, res){
console.dir(res);
});
unmute an existing monitor
the id of the monitor to unmute
optional, a scope to apply the unmute to (e.g. "role:db")
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.unmute(1234, function(err, res){
console.dir(res);
});
unmute all monitors
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.monitor.unmuteAll(function(err, res){
console.dir(res);
});
create a new screenboard
the name of the screenboard
an array of widgets, see http://docs.datadoghq.com/api/screenboards/ for more info
optional, a object which can contain any of the following keys
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var boardTitle = "my screenboard";
var widgets = [
{
type: "image",
height: 20,
width: 32,
y: 7,
x: 32,
url: "https://path/to/image.jpg"
}
];
var options = {
templateVariables: [
{
name: "host1",
prefix: "host",
"default": "host:my-host"
}
],
description: "it is super awesome"
};
dogapi.screenboard.create(
boardTitle, widgets, options,
function(err, res){
console.dir(res);
}
);
update an existing screenboard
the id of the screenboard to update
the name of the screenboard
an array of widgets, see http://docs.datadoghq.com/api/screenboards/ for more info
optional, a object which can contain any of the following keys
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var boardTitle = "my screenboard";
var widgets = [
{
type: "image",
height: 20,
width: 32,
y: 7,
x: 32,
url: "https://path/to/image.jpg"
}
];
var options = {
description: "it is super awesome"
};
dogapi.screenboard.update(
1234, boardTitle, widgets, options,
function(err, res){
console.dir(res);
}
);
delete an existing screenboard
the id of the screenboard to delete
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.screenboard.remove(1234, function(err, res){
console.dir(res);
});
get the info of a single existing screenboard
the id of the screenboard to fetch
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.screenboard.get(1234, function(err, res){
console.dir(res);
});
get all existing screenboards
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.screenboard.getAll(function(err, res){
console.dir(res);
});
search for metrics and hosts from the past 24 hours
the seach query to perform (e.g. "app1" or "hosts:app1" or "metrics:response")
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var query = "app";
dogapi.search.query(query, function(err, res){
console.dir(res);
});
post an update to a service check
the check name (e.g. "app.ok")
the name of the host submitting the check
one of dogapi.OK
, dogapi.WARNING
, dogapi.CRITICAL
or dogapi.UNKNOWN
optional, an object containing any of the following
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var check = "app.ok";
var hostName = "some.machine";
dogapi.serviceCheck.check(
check, hostName, dogapi.WARNING, 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.getAll(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.remove("host.name", function(err, results){
console.dir(results);
});
add a new timeboard
the title of the timeboard
the description of the timeboard
an array of objects with the following keys
{"requests": [{"q": "system.cpu.idle{*} by {host}"}
optional, an array of objects with the following keys
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var title = "Time Keeps on Slipping";
var description = "Into the Future";
var graphs = [
{
definition: {
events: [],
requests: [
{q: "avg:system.mem.free{*}"}
],
viz: "timeseries"
},
title: "Average Memory Free"
}
];
var templateVariables = [
{
name: "host1",
prefix: "host",
"default": "host:my-host"
}
];
dogapi.timeboard.create(
title, description, graphs, templateVariables,
function(err, res){
console.dir(res);
}
);
update an existing timeboard
the id of the timeboard to update
the title of the timeboard
the description of the timeboard
an array of objects with the following keys
{"requests": [{"q": "system.cpu.idle{*} by {host}"}
optional, an array of objects with the following keys
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var title = "Time Keeps on Slipping";
var description = "Into the Future";
var graphs = [
{
definition: {
events: [],
requests: [
{q: "avg:system.mem.free{*}"}
],
viz: "timeseries"
},
title: "Average Memory Free"
}
];
var templateVariables = [
{
name: "host1",
prefix: "host",
default: "host:my-host"
}
];
dogapi.timeboard.update(
1234, title, description, graphs, templateVariables,
function(err, res){
console.dir(res);
}
);
remove an existing timeboard
the id of the timeboard to remove
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.timeboard.remove(1234, function(err, res){
console.dir(res);
});
get all existing timeboards
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.timeboard.getAll(1234, function(err, res){
console.dir(res);
});
get an existing timeboard
the id of the timeboard to get
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
dogapi.timeboard.get(1234, function(err, res){
console.dir(res);
});
invite users via e-mail
an array of email addresses to send invites to
function(err, res)
var dogapi = require("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
dogapi.initialize(options);
var emails = ["me@domain.com", "you@domain.com"];
dogapi.user.invite(emails, fuction(err, res){
console.dir(res):
});
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);
});
configure the dogapi client with your app/api keys
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");
// Optional for Proxy -------8<----------
// 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
});
// Optional for Proxy -------->8----------
var options = {
api_key: "<API_KEY_HERE>",
app_key: "<APP_KEY_HERE>",
proxy_agent: agent // Optional for Proxy
};
dogapi.initialize(options);
dogapi.event.create(...);
get the current POSIX timestamp
var dogapi = require("dogapi");
dogapi.now();
// this is the same as
parseInt(new Date().getTime() / 1000);