forked from ak2consulting/node-datadog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
52 lines (42 loc) · 1.1 KB
/
index.js
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
var request = require('request');
var DataDog = function(apiKey, applicationKey, opt_apiBaseUrl) {
if (opt_apiBaseUrl === undefined) {
opt_apiBaseUrl = 'https://app.datadoghq.com';
}
this.apiBaseUrl = opt_apiBaseUrl;
this.apiKey = apiKey;
this.applicationKey = applicationKey;
};
DataDog.prototype.postEvent = function(event, callback) {
request.post({
url: this.apiBaseUrl + '/api/v1/events',
qs: {
api_key: this.apiKey,
application_key: this.applicationKey
},
json: event
},
callback);
};
DataDog.prototype.postSeries = function(series, callback) {
request.post({
url: this.apiBaseUrl + '/api/v1/series',
qs: {
api_key: this.apiKey,
application_key: this.applicationKey
},
json: series
},
callback);
};
DataDog.prototype.search = function(queryString, callback) {
request.get({
url: this.apiBaseUrl + '/api/v1/search?q=' + queryString,
qs: {
api_key: this.apiKey,
application_key: this.applicationKey
}
},
callback);
};
module.exports = DataDog;