-
Notifications
You must be signed in to change notification settings - Fork 45
/
index.html
2064 lines (2061 loc) · 60.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!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. "[email protected]")</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("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);
});
</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. "[email protected]")</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("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);
});
</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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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. "env:staging")</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("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);
});
</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. "env:staging")</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("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);
});
</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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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 ("1_hour", "4_hours", "1_day", "2_days", and "1_week")</p>
</dd>
<dt>options["size"]</dt>
<dd><p><em>optional</em>, one of ("small", "medium", "large", "xlarge")</p>
</dd>
<dt>options["legend"]</dt>
<dd><p><em>optional</em>, "yes" or "no"</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("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);
});
</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 = "foo";
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 = "foo";
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: "normal" or "low" [defualt: "normal"]</li>
<li>host: the host name to associate with the event</li>
<li>tags: array of "tag:value"'s to associate with the event</li>
<li>alert_type: "error", "warning", "info" or "success" [defualt: "info"]</li>
<li>aggregation_key: an arbitrary string used to aggregate like events</li>
<li>source_type_name: options: "nagios", "hudson", "jenkins", "user", "my apps", "feed", "chef", "puppet", "git", "bitbucket", "fabric", "capistrano"</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("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);
});
</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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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: "low" or "normal"</li>
<li>sources: comma separated list of sources (e.g. "jenkins,user")</li>
<li>tags: comma separated list of tags (e.g. "tag:value1,tag:value2")</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("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);
});
</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("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);
});
</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("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);
});
</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("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);
});
</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. "hosts:database", "metrics:system" or "test")</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("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);
});
</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 "tag:value"'s to use for the metric</li>
<li>metric_type|type: which metric type to use ("gauge" or "count") [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("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);
});
</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 "tag:value"'s</li>
<li>host: the source hostname to use for the metrics</li>
<li>metric_type|type: the type of metric to use ("gauge" or "count") [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("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);
});
</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. "system.cpu.idle{*}by{host}")</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("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);
});
</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 "metric alert" or "service check"</p>
</dd>
<dt>query</dt>
<dd><p>the monitor query to use, you probably want to read datadog'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("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);
});
</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'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 "all", "alert", "warn", or "no data"</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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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 "all", "alert", "warn", or "no data"</li>
<li>tags: an array of "tag:value"'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("dogapi");
var options = {
api_key: "api_key",
app_key: "app_key"
};
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">