Datadog API Node.JS Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2064 lines
60 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js">
</script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(){hljs.initHighlightingOnLoad();});</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
</head>
<body>
<a class="btn btn-default" href="#top" style="position:fixed;bottom:1rem;right:1rem;z-index:100000;color:#000">Jump To Top</a>
<div id="top" class="container-fluid">
<div class="row">
<div class="col-sm-12">
<h1>Node Dogapi</h1>
<ul class="nav nav-pills">
<li role=""><a href="#comment">comment</a>
</li>
<li role=""><a href="#downtime">downtime</a>
</li>
<li role=""><a href="#embed">embed</a>
</li>
<li role=""><a href="#event">event</a>
</li>
<li role=""><a href="#graph">graph</a>
</li>
<li role=""><a href="#host">host</a>
</li>
<li role=""><a href="#infrastructure">infrastructure</a>
</li>
<li role=""><a href="#metric">metric</a>
</li>
<li role=""><a href="#monitor">monitor</a>
</li>
<li role=""><a href="#screenboard">screenboard</a>
</li>
<li role=""><a href="#search">search</a>
</li>
<li role=""><a href="#serviceCheck">serviceCheck</a>
</li>
<li role=""><a href="#tag">tag</a>
</li>
<li role=""><a href="#timeboard">timeboard</a>
</li>
<li role=""><a href="#user">user</a>
</li>
<li role=""><a href="#client">client</a>
</li>
<li role=""><a href="#dogapi">dogapi</a>
</li>
</ul>
</div>
</div>
<section id="comment" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">comment</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#comment-create">create</a></li>
<li role"presentation"><a href="#comment-update">update</a></li>
<li role"presentation"><a href="#comment-remove">remove</a></li>
</ul>
<div class="function row" id="comment-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(message, properties, callback)</h3>
<div class="col-md-6">
<p>create a new comment</p>
<h4>Parameters:</h4>
<dl>
<dt>message</dt>
<dd><p>the message of the comment</p>
</dd>
<dt>properties</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>handle: the handle to associate the comment with (e.g. &quot;user@domain.com&quot;)</li>
<li>related_event_id: the event to associate the comment with</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.comment.create(&quot;a comment message&quot;, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="comment-update">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">update(commentId, message, handle, callback)</h3>
<div class="col-md-6">
<p>update an existing comment</p>
<h4>Parameters:</h4>
<dl>
<dt>commentId</dt>
<dd><p>the id of the comment to update</p>
</dd>
<dt>message</dt>
<dd><p>the message of the comment</p>
</dd>
<dt>handle</dt>
<dd><p><em>optional</em>, the handle to associate the comment with (e.g. &quot;user@domain.com&quot;)</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.comment.update(1234, &quot;new message&quot;, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="comment-remove">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">remove(commentId, callback)</h3>
<div class="col-md-6">
<p>remove a comment</p>
<h4>Parameters:</h4>
<dl>
<dt>commentId</dt>
<dd><p>the id of the comment to remove</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.comment.remove(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="downtime" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">downtime</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#downtime-create">create</a></li>
<li role"presentation"><a href="#downtime-update">update</a></li>
<li role"presentation"><a href="#downtime-remove">remove</a></li>
<li role"presentation"><a href="#downtime-get">get</a></li>
<li role"presentation"><a href="#downtime-getAll">getAll</a></li>
</ul>
<div class="function row" id="downtime-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(scope, properties, callback)</h3>
<div class="col-md-6">
<p>schedule a new downtime</p>
<h4>Parameters:</h4>
<dl>
<dt>scope</dt>
<dd><p>string scope that the downtime should apply to (e.g. &quot;env:staging&quot;)</p>
</dd>
<dt>properties</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>start: POSIX timestamp for when the downtime should start</li>
<li>end: POSIX timestamp for when the downtime should end</li>
<li>message: a string message to accompany the downtime</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.downtime.create(&quot;env:staging&quot;, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="downtime-update">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">update(downtimeId, properties, callback)</h3>
<div class="col-md-6">
<p>update an existing downtime</p>
<h4>Parameters:</h4>
<dl>
<dt>downtimeId</dt>
<dd><p>the id the downtie to update</p>
</dd>
<dt>properties</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>scope: the scope the downtime should be changed to (e.g. &quot;env:staging&quot;)</li>
<li>start: POSIX timestamp for when the downtime should start</li>
<li>end: POSIX timestamp for when the downtime should end</li>
<li>message: a string message to accompany the downtime</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var properties = {
scope: &quot;env:staging&quot;
};
dogapi.downtime.update(1234, properties, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="downtime-remove">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">remove(downtimeId, callback)</h3>
<div class="col-md-6">
<p>delete a scheduled downtime</p>
<h4>Parameters:</h4>
<dl>
<dt>downtimeId</dt>
<dd><p>the id of the downtime</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.downtime.remove(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="downtime-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(downtimeId, callback)</h3>
<div class="col-md-6">
<p>get a scheduled downtimes details</p>
<h4>Parameters:</h4>
<dl>
<dt>downtimeId</dt>
<dd><p>the id of the downtime</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.downtime.get(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="downtime-getAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">getAll(callback)</h3>
<div class="col-md-6">
<p>get all downtimes details</p>
<h4>Parameters:</h4>
<dl>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.downtime.getAll(function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="embed" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">embed</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#embed-create">create</a></li>
<li role"presentation"><a href="#embed-revoke">revoke</a></li>
<li role"presentation"><a href="#embed-getAll">getAll</a></li>
<li role"presentation"><a href="#embed-get">get</a></li>
</ul>
<div class="function row" id="embed-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(graph_json, options, options["timeframe"], options["size"], options["legend"], options["title"], callback)</h3>
<div class="col-md-6">
<p>create an embed graph of a metric query</p>
<h4>Parameters:</h4>
<dl>
<dt>graph_json</dt>
<dd><p>The request array to pass create in the embed</p>
</dd>
<dt>options</dt>
<dd><p><em>optional</em>, object of extra parameters to pass to the embed create (see options[*] params)</p>
</dd>
<dt>options["timeframe"]</dt>
<dd><p><em>optional</em>, one of (&quot;1_hour&quot;, &quot;4_hours&quot;, &quot;1_day&quot;, &quot;2_days&quot;, and &quot;1_week&quot;)</p>
</dd>
<dt>options["size"]</dt>
<dd><p><em>optional</em>, one of (&quot;small&quot;, &quot;medium&quot;, &quot;large&quot;, &quot;xlarge&quot;)</p>
</dd>
<dt>options["legend"]</dt>
<dd><p><em>optional</em>, &quot;yes&quot; or &quot;no&quot;</p>
</dd>
<dt>options["title"]</dt>
<dd><p><em>optional</em>, the title of the embed</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var query = &quot;system.cpu.idle{*}&quot;;
var graphJSON = {
viz: &quot;timeseries&quot;,
requests: [
{
q: query,
aggregator: &quot;avg&quot;,
conditional_formats: [],
type: &quot;area&quot;
}
]
}
var options = {
timeframe: &quot;1_hour&quot;,
size: &quot;xlarge&quot;,
legend: &quot;yes&quot;,
title: &quot;my awesome embed&quot;
};
dogapi.embed.create(graphJSON, options, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="embed-revoke">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">revoke(embedId, callback)</h3>
<div class="col-md-6">
<p>delete an embed with a specific id</p>
<h4>Parameters:</h4>
<dl>
<dt>embedId</dt>
<dd><p>the id of the embed to delete</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var embedid = &quot;foo&quot;;
dogapi.embed.revoke(embedid, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="embed-getAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">getAll(callback)</h3>
<div class="col-md-6">
<p>get all embeds from datadog</p>
<h4>Parameters:</h4>
<dl>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">dogapi.embed.getAll(function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="embed-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(embedId, callback)</h3>
<div class="col-md-6">
<p>get a single embed</p>
<h4>Parameters:</h4>
<dl>
<dt>embedId</dt>
<dd><p>the id of the embed to get</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var embedId = &quot;foo&quot;;
dogapi.embed.get(embedId, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="event" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">event</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#event-create">create</a></li>
<li role"presentation"><a href="#event-get">get</a></li>
<li role"presentation"><a href="#event-query">query</a></li>
</ul>
<div class="function row" id="event-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(title, text, properties, callback)</h3>
<div class="col-md-6">
<p>create a new event</p>
<h4>Parameters:</h4>
<dl>
<dt>title</dt>
<dd><p>the title of the event</p>
</dd>
<dt>text</dt>
<dd><p>the body of the event</p>
</dd>
<dt>properties</dt>
<dd><p>an <em>optional</em> object continaing any of the following additional <em>optional</em> properties</p>
<ul>
<li>date_happened: POSIX timestamp of when it happened</li>
<li>priority: &quot;normal&quot; or &quot;low&quot; [defualt: &quot;normal&quot;]</li>
<li>host: the host name to associate with the event</li>
<li>tags: array of &quot;tag:value&quot;&#39;s to associate with the event</li>
<li>alert_type: &quot;error&quot;, &quot;warning&quot;, &quot;info&quot; or &quot;success&quot; [defualt: &quot;info&quot;]</li>
<li>aggregation_key: an arbitrary string used to aggregate like events</li>
<li>source_type_name: options: &quot;nagios&quot;, &quot;hudson&quot;, &quot;jenkins&quot;, &quot;user&quot;, &quot;my apps&quot;, &quot;feed&quot;, &quot;chef&quot;, &quot;puppet&quot;, &quot;git&quot;, &quot;bitbucket&quot;, &quot;fabric&quot;, &quot;capistrano&quot;</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript"> var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var title = &quot;some new event&quot;;
var text = &quot;IT HAPPENED!&quot;;
dogapi.event.create(title, text, function(err, res){
console.dir(res);
});
title = &quot;another event&quot;;
text = &quot;IT HAPPENED AGAIN!&quot;;
var properties = {
tags: [&quot;some:tag&quot;],
alert_type: &quot;error&quot;
};
dogapi.event.create(title, text, properties, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="event-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(eventId, callback)</h3>
<div class="col-md-6">
<p>get event details from the provided event id</p>
<h4>Parameters:</h4>
<dl>
<dt>eventId</dt>
<dd><p>the id of the event to fetch</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript"> var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.event.get(10005, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="event-query">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">query(start, end, parameters, callback)</h3>
<div class="col-md-6">
<p>query the event stream</p>
<h4>Parameters:</h4>
<dl>
<dt>start</dt>
<dd><p>POSIX timestamp for start of query</p>
</dd>
<dt>end</dt>
<dd><p>POSIX timestamp for end of query</p>
</dd>
<dt>parameters</dt>
<dd><p><em>optional</em> parameters to use for the query</p>
<ul>
<li>priority: &quot;low&quot; or &quot;normal&quot;</li>
<li>sources: comma separated list of sources (e.g. &quot;jenkins,user&quot;)</li>
<li>tags: comma separated list of tags (e.g. &quot;tag:value1,tag:value2&quot;)</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript"> var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var now = parseInt(new Date().getTime() / 1000);
var then = now - 3600; // an hour ago
var parameters = {
tags: &quot;some:tag&quot;,
sources: &quot;jenkins&quot;
};
dogapi.event.query(then, now, parameters, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="graph" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">graph</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#graph-snapshot">snapshot</a></li>
</ul>
<div class="function row" id="graph-snapshot">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">snapshot(query, from, to, eventQuery, callback)</h3>
<div class="col-md-6">
<p>take a snapshot of a metric query</p>
<h4>Parameters:</h4>
<dl>
<dt>query</dt>
<dd><p>the metric query to use for the snapshot</p>
</dd>
<dt>from</dt>
<dd><p>POSIX timestamp for the beginning of the query</p>
</dd>
<dt>to</dt>
<dd><p>POSIX timestamp for the end of the query</p>
</dd>
<dt>eventQuery</dt>
<dd><p><em>optional</em>, an event query to overlay event bands on the snapshot</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var query = &quot;system.cpu.idle{*}&quot;;
var to = dogapi.now();
var from = to - 3600; // an hour ago
dogapi.graph.snapshot(query, from, to, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="host" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">host</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#host-mute">mute</a></li>
<li role"presentation"><a href="#host-unmute">unmute</a></li>
</ul>
<div class="function row" id="host-mute">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">mute(hostname, options, callback)</h3>
<div class="col-md-6">
<p>mute the given host, if it is not already muted</p>
<h4>Parameters:</h4>
<dl>
<dt>hostname</dt>
<dd><p>the hostname of the host to mute</p>
</dd>
<dt>options</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>end: POSIX timestamp for when the mute should end</li>
<li>override: whether or not to override the end for an existing mute</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.host.mute(&quot;my.host.name&quot;, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="host-unmute">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">unmute(hostname, callback)</h3>
<div class="col-md-6">
<p>unmute the given host, if it is not already unmuted</p>
<h4>Parameters:</h4>
<dl>
<dt>hostname</dt>
<dd><p>the hostname of the host to unmute</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.host.unmute(&quot;my.host.name&quot;, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="infrastructure" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">infrastructure</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#infrastructure-search">search</a></li>
</ul>
<div class="function row" id="infrastructure-search">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">search(query, callback)</h3>
<div class="col-md-6">
<p>search for metrics or hosts</p>
<h4>Parameters:</h4>
<dl>
<dt>query</dt>
<dd><p>the query to use for search see <a href="http://docs.datadoghq.com/api/#search">datadog docs</a>
for examples of the query (e.g. &quot;hosts:database&quot;, &quot;metrics:system&quot; or &quot;test&quot;)</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.infrastructure.search(&quot;hosts:database&quot;, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="metric" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">metric</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#metric-send">send</a></li>
<li role"presentation"><a href="#metric-send_all">send_all</a></li>
<li role"presentation"><a href="#metric-query">query</a></li>
</ul>
<div class="function row" id="metric-send">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">send(metric, points, extra, callback)</h3>
<div class="col-md-6">
<p>submit a new metric</p>
<h4>Parameters:</h4>
<dl>
<dt>metric</dt>
<dd><p>the metric name</p>
</dd>
<dt>points</dt>
<dd><p>a single data point (e.g. <code>50</code>), an array of data points (e.g. <code>[50, 100]</code>)
or an array of <code>[timestamp, value]</code> elements (e.g. <code>[[now, 50], [now, 100]]</code>)</p>
</dd>
<dt>extra</dt>
<dd><p><em>optional</em>, object which can contain the following keys</p>
<ul>
<li>host: the host source of the metric</li>
<li>tags: array of &quot;tag:value&quot;&#39;s to use for the metric</li>
<li>metric_type|type: which metric type to use (&quot;gauge&quot; or &quot;count&quot;) [default: gauge]</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.metric.send(&quot;my.metric&quot;, 1000, function(err, results){
console.dir(results);
});
dogapi.metric.send(&quot;my.metric&quot;, [500, 1000], function(err, results){
console.dir(results);
});
var now = parseInt(new Date().getTime() / 1000);
dogapi.metric.send(&quot;my.metric&quot;, [[now, 1000]], function(err, results){
console.dir(results);
});
dogapi.metric.send(&quot;my.counter&quot;, 5, {type: &quot;count&quot;}, function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
<div class="function row" id="metric-send_all">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">send_all(metrics, callback)</h3>
<div class="col-md-6">
<p>send a list of metrics</p>
<h4>Parameters:</h4>
<dl>
<dt>metrics</dt>
<dd><p>an array of metrics where each element is an object with the following keys</p>
<ul>
<li>metric: the name of the metric</li>
<li>points: a single data point (e.g. <code>50</code>), an array of data points (e.g. <code>[50, 100]</code>) or an array of <code>[timestamp, value]</code> elements (e.g. <code>[[now, 50], [now, 100]]</code>)</li>
<li>tags: an array of &quot;tag:value&quot;&#39;s</li>
<li>host: the source hostname to use for the metrics</li>
<li>metric_type|type: the type of metric to use (&quot;gauge&quot; or &quot;count&quot;) [default: gauge]</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var now = parseInt(new Date().getTime() / 1000);
var metrics = [
{
metric: &quot;my.metric&quot;,
points: [[now, 1000]],
tags: [&quot;tag:value&quot;]
},
{
metric: &quot;another.metric&quot;,
points: [50, 1000]
},
{
metric: &quot;another.metric&quot;,
points: 1000
}
];
dogapi.metric.send_all(metrics, function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
<div class="function row" id="metric-query">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">query(from, to, query, callback)</h3>
<div class="col-md-6">
<p>make a metric query</p>
<h4>Parameters:</h4>
<dl>
<dt>from</dt>
<dd><p>POSIX timestamp for start of query</p>
</dd>
<dt>to</dt>
<dd><p>POSIX timestamp for end of query</p>
</dd>
<dt>query</dt>
<dd><p>the string query to perform (e.g. &quot;system.cpu.idle{*}by{host}&quot;)</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var now = parseInt(new Date().getTime() / 1000);
var then = now - 3600; // one hour ago
var query = &quot;system.cpu.idle{*}by{host}&quot;;
dogapi.metric.query(then, now, query, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="monitor" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">monitor</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#monitor-create">create</a></li>
<li role"presentation"><a href="#monitor-get">get</a></li>
<li role"presentation"><a href="#monitor-getAll">getAll</a></li>
<li role"presentation"><a href="#monitor-update">update</a></li>
<li role"presentation"><a href="#monitor-remove">remove</a></li>
<li role"presentation"><a href="#monitor-mute">mute</a></li>
<li role"presentation"><a href="#monitor-muteAll">muteAll</a></li>
<li role"presentation"><a href="#monitor-unmute">unmute</a></li>
<li role"presentation"><a href="#monitor-unmuteAll">unmuteAll</a></li>
</ul>
<div class="function row" id="monitor-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(type, query, properties, callback)</h3>
<div class="col-md-6">
<p>create a new monitor</p>
<h4>Parameters:</h4>
<dl>
<dt>type</dt>
<dd><p>one of &quot;metric alert&quot; or &quot;service check&quot;</p>
</dd>
<dt>query</dt>
<dd><p>the monitor query to use, you probably want to read datadog&#39;s <a href="http://docs.datadoghq.com/api/#monitor-create">monitor create</a> docs</p>
</dd>
<dt>properties</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>name: the name of the monitor</li>
<li>message: the message for the monitor</li>
<li>tags: a list of strings as tags to associate with the monitor</li>
<li>options: an object, to see available options please see the <a href="http://docs.datadoghq.com/api/#monitor-create">monitor create</a> docs</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var metricType = &quot;metric alert&quot;;
var query = &quot;avg(last_1h):sum:system.net.bytes_rcvd{host:host0} &gt; 100&quot;;
dogapi.monitor.create(metricType, query, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(monitorId, groupStates, callback)</h3>
<div class="col-md-6">
<p>get an existing monitor&#39;s details</p>
<h4>Parameters:</h4>
<dl>
<dt>monitorId</dt>
<dd><p>the id of the monitor</p>
</dd>
<dt>groupStates</dt>
<dd><p>an array containing any of the following &quot;all&quot;, &quot;alert&quot;, &quot;warn&quot;, or &quot;no data&quot;</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.get(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-getAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">getAll(options, callback)</h3>
<div class="col-md-6">
<p>get all monitors</p>
<h4>Parameters:</h4>
<dl>
<dt>options</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>group_states: an array containing any of the following &quot;all&quot;, &quot;alert&quot;, &quot;warn&quot;, or &quot;no data&quot;</li>
<li>tags: an array of &quot;tag:value&quot;&#39;s to filter on</li>
<li>monitor_tags: a comma separated list indicating what service and/or custom tags</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.getAll(function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-update">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">update(monitorId, query, properties, callback)</h3>
<div class="col-md-6">
<p>update a monitor&#39;s details</p>
<h4>Parameters:</h4>
<dl>
<dt>monitorId</dt>
<dd><p>the id of the monitor to edit</p>
</dd>
<dt>query</dt>
<dd><p>the query that the monitor should have, see the <a href="http://docs.datadoghq.com/api/#monitor-create">monitor create</a> docs for more info</p>
</dd>
<dt>properties</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>name: the name of the monitor</li>
<li>message: the message for the monitor</li>
<li>tags: a list of strings as tags to associate with the monitor</li>
<li>options: an object, to see available options please see the <a href="http://docs.datadoghq.com/api/#monitor-create">monitor create</a> docs</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var query = &quot;avg(last_1h):sum:system.net.bytes_rcvd{host:host0} &gt; 100&quot;;
dogapi.monitor.update(1234, query, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-remove">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">remove(monitorId, callback)</h3>
<div class="col-md-6">
<p>delete an existing monitor</p>
<h4>Parameters:</h4>
<dl>
<dt>monitorId</dt>
<dd><p>the id of the monitor to remove</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.remove(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-mute">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">mute(monitorId, options, callback)</h3>
<div class="col-md-6">
<p>mute an existing monitor</p>
<h4>Parameters:</h4>
<dl>
<dt>monitorId</dt>
<dd><p>the id of the monitor to mute</p>
</dd>
<dt>options</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>scope: the scope to mute (e.g. &quot;role:db&quot;)</li>
<li>end: POSIX timestamp indicating when the mute should end</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.mute(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-muteAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">muteAll(callback)</h3>
<div class="col-md-6">
<p>mute all monitors</p>
<h4>Parameters:</h4>
<dl>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.muteAll(function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-unmute">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">unmute(monitorId, scope, callback)</h3>
<div class="col-md-6">
<p>unmute an existing monitor</p>
<h4>Parameters:</h4>
<dl>
<dt>monitorId</dt>
<dd><p>the id of the monitor to unmute</p>
</dd>
<dt>scope</dt>
<dd><p><em>optional</em>, a scope to apply the unmute to (e.g. &quot;role:db&quot;)</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.unmute(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="monitor-unmuteAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">unmuteAll(callback)</h3>
<div class="col-md-6">
<p>unmute all monitors</p>
<h4>Parameters:</h4>
<dl>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.monitor.unmuteAll(function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="screenboard" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">screenboard</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#screenboard-create">create</a></li>
<li role"presentation"><a href="#screenboard-update">update</a></li>
<li role"presentation"><a href="#screenboard-remove">remove</a></li>
<li role"presentation"><a href="#screenboard-get">get</a></li>
<li role"presentation"><a href="#screenboard-getAll">getAll</a></li>
<li role"presentation"><a href="#screenboard-share">share</a></li>
</ul>
<div class="function row" id="screenboard-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(boardTitle, widgets, options, callback)</h3>
<div class="col-md-6">
<p>create a new screenboard</p>
<h4>Parameters:</h4>
<dl>
<dt>boardTitle</dt>
<dd><p>the name of the screenboard</p>
</dd>
<dt>widgets</dt>
<dd><p>an array of widgets, see <a href="http://docs.datadoghq.com/api/screenboards/">http://docs.datadoghq.com/api/screenboards/</a> for more info</p>
</dd>
<dt>options</dt>
<dd><p><em>optional</em>, a object which can contain any of the following keys</p>
<ul>
<li>description: description of the screenboard</li>
<li>templateVariables: |
an array of objects with the following keys<ul>
<li>name: the name of the variable</li>
<li>prefix: <em>optional</em>, the tag prefix for this variable</li>
<li>default: <em>optional</em>, the default value for this tag</li>
</ul>
</li>
<li>width: the width of the screenboard in pixels</li>
<li>height: the height of the screenboard in pixels</li>
<li>readOnly: the read-only status of the screenboard</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var boardTitle = &quot;my screenboard&quot;;
var widgets = [
{
type: &quot;image&quot;,
height: 20,
width: 32,
y: 7,
x: 32,
url: &quot;https://path/to/image.jpg&quot;
}
];
var options = {
templateVariables: [
{
name: &quot;host1&quot;,
prefix: &quot;host&quot;,
&quot;default&quot;: &quot;host:my-host&quot;
}
],
description: &quot;it is super awesome&quot;
};
dogapi.screenboard.create(
boardTitle, widgets, options,
function(err, res){
console.dir(res);
}
);
</code></pre>
</div>
</div>
<div class="function row" id="screenboard-update">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">update(boardId, boardTitle, widgets, options, callback)</h3>
<div class="col-md-6">
<p>update an existing screenboard</p>
<h4>Parameters:</h4>
<dl>
<dt>boardId</dt>
<dd><p>the id of the screenboard to update</p>
</dd>
<dt>boardTitle</dt>
<dd><p>the name of the screenboard</p>
</dd>
<dt>widgets</dt>
<dd><p>an array of widgets, see <a href="http://docs.datadoghq.com/api/screenboards/">http://docs.datadoghq.com/api/screenboards/</a> for more info</p>
</dd>
<dt>options</dt>
<dd><p><em>optional</em>, a object which can contain any of the following keys</p>
<ul>
<li>description: description of the screenboard</li>
<li>templateVariables: |
an array of objects with the following keys<ul>
<li>name: the name of the variable</li>
<li>prefix: <em>optional</em>, the tag prefix for this variable</li>
<li>default: <em>optional</em>, the default value for this tag</li>
</ul>
</li>
<li>width: the width of the screenboard in pixels</li>
<li>height: the height of the screenboard in pixels</li>
<li>readOnly: the read-only status of the screenboard</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var boardTitle = &quot;my screenboard&quot;;
var widgets = [
{
type: &quot;image&quot;,
height: 20,
width: 32,
y: 7,
x: 32,
url: &quot;https://path/to/image.jpg&quot;
}
];
var options = {
description: &quot;it is super awesome&quot;
};
dogapi.screenboard.update(
1234, boardTitle, widgets, options,
function(err, res){
console.dir(res);
}
);
</code></pre>
</div>
</div>
<div class="function row" id="screenboard-remove">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">remove(boardId, callback)</h3>
<div class="col-md-6">
<p>delete an existing screenboard</p>
<h4>Parameters:</h4>
<dl>
<dt>boardId</dt>
<dd><p>the id of the screenboard to delete</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.screenboard.remove(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="screenboard-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(boardId, callback)</h3>
<div class="col-md-6">
<p>get the info of a single existing screenboard</p>
<h4>Parameters:</h4>
<dl>
<dt>boardId</dt>
<dd><p>the id of the screenboard to fetch</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.screenboard.get(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="screenboard-getAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">getAll(callback)</h3>
<div class="col-md-6">
<p>get all existing screenboards</p>
<h4>Parameters:</h4>
<dl>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.screenboard.getAll(function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="screenboard-share">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">share(boardId, callback)</h3>
<div class="col-md-6">
<p>share an existing screenboard</p>
<h4>Parameters:</h4>
<dl>
<dt>boardId</dt>
<dd><p>the id of the screenboard to share</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.screenboard.share(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="search" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">search</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#search-query">query</a></li>
</ul>
<div class="function row" id="search-query">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">query(query, callback)</h3>
<div class="col-md-6">
<p>search for metrics and hosts from the past 24 hours</p>
<h4>Parameters:</h4>
<dl>
<dt>query</dt>
<dd><p>the seach query to perform (e.g. &quot;app1&quot; or &quot;hosts:app1&quot; or &quot;metrics:response&quot;)</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var query = &quot;app&quot;;
dogapi.search.query(query, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="serviceCheck" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">serviceCheck</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#serviceCheck-check">check</a></li>
</ul>
<div class="function row" id="serviceCheck-check">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">check(check, hostName, status, parameters, callback)</h3>
<div class="col-md-6">
<p>post an update to a service check</p>
<h4>Parameters:</h4>
<dl>
<dt>check</dt>
<dd><p>the check name (e.g. &quot;app.ok&quot;)</p>
</dd>
<dt>hostName</dt>
<dd><p>the name of the host submitting the check</p>
</dd>
<dt>status</dt>
<dd><p>one of <code>dogapi.OK</code>, <code>dogapi.WARNING</code>, <code>dogapi.CRITICAL</code> or <code>dogapi.UNKNOWN</code></p>
</dd>
<dt>parameters</dt>
<dd><p><em>optional</em>, an object containing any of the following</p>
<ul>
<li>timestamp: POSIX timestamp for when the check happened</li>
<li>message: string message to accompany the check</li>
<li>tags: an array of &quot;tag:value&quot;&#39;s associated with the check</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript"> var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var check = &quot;app.ok&quot;;
var hostName = &quot;some.machine&quot;;
dogapi.serviceCheck.check(
check, hostName, dogapi.WARNING, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="tag" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">tag</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#tag-getAll">getAll</a></li>
<li role"presentation"><a href="#tag-get">get</a></li>
<li role"presentation"><a href="#tag-create">create</a></li>
<li role"presentation"><a href="#tag-update">update</a></li>
<li role"presentation"><a href="#tag-remove">remove</a></li>
</ul>
<div class="function row" id="tag-getAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">getAll(source, callback)</h3>
<div class="col-md-6">
<p>get all host tags</p>
<h4>Parameters:</h4>
<dl>
<dt>source</dt>
<dd><p><em>optional</em>, only show tags for a particular source [default: null]</p>
</dd>
<dt>callback</dt>
<dd><p>function callback(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.tag.getAll(function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
<div class="function row" id="tag-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(hostname, options, callback)</h3>
<div class="col-md-6">
<p>get the host tags for a provided host name or host id</p>
<h4>Parameters:</h4>
<dl>
<dt>hostname</dt>
<dd><p>the hostname or host id</p>
</dd>
<dt>options</dt>
<dd><p><em>optional</em>, an object of options for the query allowing the following</p>
<ul>
<li>source: the source of the tags (e.g. chef, puppet, users, etc) [default: null]</li>
<li>by_source: whether or not to group the results by source [default: false]</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function callback(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.tag.get(&quot;host.name&quot;, function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
<div class="function row" id="tag-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(hostname, tags, source, callback)</h3>
<div class="col-md-6">
<p>assign new host tags to the provided host name or host id</p>
<h4>Parameters:</h4>
<dl>
<dt>hostname</dt>
<dd><p>the hostname or host id</p>
</dd>
<dt>tags</dt>
<dd><p>list of <code>&lt;tag&gt;:&lt;value&gt;</code> tags to assign to the server</p>
</dd>
<dt>source</dt>
<dd><p><em>optional</em>, the source of the tags (e.g. chef, puppet, etc) [default: users]</p>
</dd>
<dt>callback</dt>
<dd><p>function callback(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.tag.create(&quot;host.name&quot;, [&quot;role:webserver&quot;], function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
<div class="function row" id="tag-update">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">update(hostname, tags, source, callback)</h3>
<div class="col-md-6">
<p>update the host tags for the provided host name or host id</p>
<h4>Parameters:</h4>
<dl>
<dt>hostname</dt>
<dd><p>the hostname or host id</p>
</dd>
<dt>tags</dt>
<dd><p>list of <code>&lt;tag&gt;:&lt;value&gt;</code> tags to assign to the server</p>
</dd>
<dt>source</dt>
<dd><p><em>optional</em>, the source of the tags (e.g. chef, puppet, etc) [default: users]</p>
</dd>
<dt>callback</dt>
<dd><p>function callback(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.tag.update(&quot;host.name&quot;, function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
<div class="function row" id="tag-remove">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">remove(hostname, source, callback)</h3>
<div class="col-md-6">
<p>delete the host tags for the provided host name or host id</p>
<h4>Parameters:</h4>
<dl>
<dt>hostname</dt>
<dd><p>the hostname or host id</p>
</dd>
<dt>source</dt>
<dd><p><em>optional</em>, the source of the tags (e.g. chef, puppet, etc) [default: users]</p>
</dd>
<dt>callback</dt>
<dd><p>function callback(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.tag.remove(&quot;host.name&quot;, function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
</section>
<section id="timeboard" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">timeboard</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#timeboard-create">create</a></li>
<li role"presentation"><a href="#timeboard-update">update</a></li>
<li role"presentation"><a href="#timeboard-remove">remove</a></li>
<li role"presentation"><a href="#timeboard-getAll">getAll</a></li>
<li role"presentation"><a href="#timeboard-get">get</a></li>
</ul>
<div class="function row" id="timeboard-create">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">create(title, description, graphs, templateVariables, callback)</h3>
<div class="col-md-6">
<p>add a new timeboard</p>
<h4>Parameters:</h4>
<dl>
<dt>title</dt>
<dd><p>the title of the timeboard</p>
</dd>
<dt>description</dt>
<dd><p>the description of the timeboard</p>
</dd>
<dt>graphs</dt>
<dd><p>an array of objects with the following keys</p>
<ul>
<li>title: the name of the graph</li>
<li>definition: an object containing the graph definition, e.g. <code>{&quot;requests&quot;: [{&quot;q&quot;: &quot;system.cpu.idle{*} by {host}&quot;}</code></li>
</ul>
</dd>
<dt>templateVariables</dt>
<dd><p><em>optional</em>, an array of objects with the following keys</p>
<ul>
<li>name: the name of the variable</li>
<li>prefix: <em>optional</em>, the tag prefix for this variable</li>
<li>default: <em>optional</em>, the default value for this tag</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var title = &quot;Time Keeps on Slipping&quot;;
var description = &quot;Into the Future&quot;;
var graphs = [
{
definition: {
events: [],
requests: [
{q: &quot;avg:system.mem.free{*}&quot;}
],
viz: &quot;timeseries&quot;
},
title: &quot;Average Memory Free&quot;
}
];
var templateVariables = [
{
name: &quot;host1&quot;,
prefix: &quot;host&quot;,
&quot;default&quot;: &quot;host:my-host&quot;
}
];
dogapi.timeboard.create(
title, description, graphs, templateVariables,
function(err, res){
console.dir(res);
}
);
</code></pre>
</div>
</div>
<div class="function row" id="timeboard-update">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">update(dashId, title, description, graphs, templateVariables, callback)</h3>
<div class="col-md-6">
<p>update an existing timeboard</p>
<h4>Parameters:</h4>
<dl>
<dt>dashId</dt>
<dd><p>the id of the timeboard to update</p>
</dd>
<dt>title</dt>
<dd><p>the title of the timeboard</p>
</dd>
<dt>description</dt>
<dd><p>the description of the timeboard</p>
</dd>
<dt>graphs</dt>
<dd><p>an array of objects with the following keys</p>
<ul>
<li>title: the name of the graph</li>
<li>definition: an object containing the graph definition, e.g. <code>{&quot;requests&quot;: [{&quot;q&quot;: &quot;system.cpu.idle{*} by {host}&quot;}</code></li>
</ul>
</dd>
<dt>templateVariables</dt>
<dd><p><em>optional</em>, an array of objects with the following keys</p>
<ul>
<li>name: the name of the variable</li>
<li>prefix: <em>optional</em>, the tag prefix for this variable</li>
<li>default: <em>optional</em>, the default value for this tag</li>
</ul>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var title = &quot;Time Keeps on Slipping&quot;;
var description = &quot;Into the Future&quot;;
var graphs = [
{
definition: {
events: [],
requests: [
{q: &quot;avg:system.mem.free{*}&quot;}
],
viz: &quot;timeseries&quot;
},
title: &quot;Average Memory Free&quot;
}
];
var templateVariables = [
{
name: &quot;host1&quot;,
prefix: &quot;host&quot;,
default: &quot;host:my-host&quot;
}
];
dogapi.timeboard.update(
1234, title, description, graphs, templateVariables,
function(err, res){
console.dir(res);
}
);
</code></pre>
</div>
</div>
<div class="function row" id="timeboard-remove">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">remove(dashId, callback)</h3>
<div class="col-md-6">
<p>remove an existing timeboard</p>
<h4>Parameters:</h4>
<dl>
<dt>dashId</dt>
<dd><p>the id of the timeboard to remove</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.timeboard.remove(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="timeboard-getAll">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">getAll(callback)</h3>
<div class="col-md-6">
<p>get all existing timeboards</p>
<h4>Parameters:</h4>
<dl>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.timeboard.getAll(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
<div class="function row" id="timeboard-get">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">get(dashId, callback)</h3>
<div class="col-md-6">
<p>get an existing timeboard</p>
<h4>Parameters:</h4>
<dl>
<dt>dashId</dt>
<dd><p>the id of the timeboard to get</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.timeboard.get(1234, function(err, res){
console.dir(res);
});
</code></pre>
</div>
</div>
</section>
<section id="user" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">user</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#user-invite">invite</a></li>
</ul>
<div class="function row" id="user-invite">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">invite(emails, callback)</h3>
<div class="col-md-6">
<p>invite users via e-mail</p>
<h4>Parameters:</h4>
<dl>
<dt>emails</dt>
<dd><p>an array of email addresses to send invites to</p>
</dd>
<dt>callback</dt>
<dd><p>function(err, res)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
var emails = [&quot;me@domain.com&quot;, &quot;you@domain.com&quot;];
dogapi.user.invite(emails, fuction(err, res){
console.dir(res):
});
</code></pre>
</div>
</div>
</section>
<section id="client" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">client</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#client-client">client</a></li>
<li role"presentation"><a href="#client-request">request</a></li>
</ul>
<div class="function row" id="client-client">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">client()</h3>
<div class="col-md-6">
<p>the constructor for <em>client</em> object</p>
</div>
<div class="col-md-6">
<p>See <a href="#client-request">client.request</a></p>
</div>
</div>
<div class="function row" id="client-request">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">request(method, path, params, callback)</h3>
<div class="col-md-6">
<p>used to make a raw request to the datadog api</p>
<h4>Parameters:</h4>
<dl>
<dt>method</dt>
<dd><p>http method GET, POST, PUT, DELETE</p>
</dd>
<dt>path</dt>
<dd><p>the api url path e.g. /tags/hosts</p>
</dd>
<dt>params</dt>
<dd><p>an object which allows the keys <code>query</code> or <code>body</code></p>
</dd>
<dt>callback</dt>
<dd><p>function to call on success/failure callback(err, result)</p>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
var options = {
api_key: &quot;api_key&quot;,
app_key: &quot;app_key&quot;
};
dogapi.initialize(options);
dogapi.client.request(&quot;GET&quot;, &quot;/url/path&quot;, {}, function(err, results){
console.dir(results);
});
</code></pre>
</div>
</div>
</section>
<section id="dogapi" class="col-sm-12">
<div class="row">
<h2 class="bg-primary" style="text-indent:1rem">dogapi</h2></div>
<ul class="nav nav-pills">
<li role"presentation"><a href="#dogapi-initialize">initialize</a></li>
<li role"presentation"><a href="#dogapi-now">now</a></li>
</ul>
<div class="function row" id="dogapi-initialize">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">initialize(options)</h3>
<div class="col-md-6">
<p>configure the dogapi client with your app/api keys</p>
<h4>Parameters:</h4>
<dl>
<dt>options</dt>
<dd><p>An object which allows you to override the default set parameters for interacting
with the datadog api. The available options are.</p>
<ul>
<li>api_key: your api key</li>
<li>app_key: your app key</li>
<li>api_version: the version of the api [default: <code>v1</code>]</li>
<li>api_host: the host to call [default: <code>api.datadoghq.com</code>]</li>
<li>proxy_agent: Optional, A Https Proxy agent.</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
// Optional for Proxy -------8&lt;----------
// Code from http://blog.vanamco.com/proxy-requests-in-node-js/
var HttpsProxyAgent = require(&quot;./httpsproxyagent&quot;);
var agent = new HttpsProxyAgent({
proxyHost: &quot;MY_PROXY_HOST&quot;,
proxyPort: 3128
});
// Optional for Proxy --------&gt;8----------
var options = {
api_key: &quot;&lt;API_KEY_HERE&gt;&quot;,
app_key: &quot;&lt;APP_KEY_HERE&gt;&quot;,
proxy_agent: agent // Optional for Proxy
};
dogapi.initialize(options);
dogapi.event.create(...);
</code></pre>
</div>
</div>
<div class="function row" id="dogapi-now">
<h3 class="bg-info" style="text-indent:.5rem;padding:.5rem;margin-top:.5rem">now()</h3>
<div class="col-md-6">
<p>get the current POSIX timestamp</p>
</div>
<div class="col-md-6">
<pre><code class="lang-javascript">var dogapi = require(&quot;dogapi&quot;);
dogapi.now();
// this is the same as
parseInt(new Date().getTime() / 1000);
</code></pre>
</div>
</div>
</section>
</div>
<a href="https://github.com/brettlangdon/node-dogapi"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a></body></html>