|
|
@ -1,5 +1,5 @@ |
|
|
var client = require("../client"); |
|
|
|
|
|
var util = require("util"); |
|
|
|
|
|
|
|
|
const client = require("../client"); |
|
|
|
|
|
const util = require("util"); |
|
|
|
|
|
|
|
|
/*section: monitor |
|
|
/*section: monitor |
|
|
*comment: create a new monitor |
|
|
*comment: create a new monitor |
|
|
@ -15,14 +15,14 @@ var util = require("util"); |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
* dogapi.initialize(options); |
|
|
* dogapi.initialize(options); |
|
|
* var metricType = "metric alert"; |
|
|
|
|
|
* var query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100"; |
|
|
|
|
|
|
|
|
* const metricType = "metric alert"; |
|
|
|
|
|
* const query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100"; |
|
|
* dogapi.monitor.create(metricType, query, function(err, res){ |
|
|
* dogapi.monitor.create(metricType, query, function(err, res){ |
|
|
* console.dir(res); |
|
|
* console.dir(res); |
|
|
* }); |
|
|
* }); |
|
|
@ -34,7 +34,7 @@ function create(type, query, properties, callback){ |
|
|
properties = {}; |
|
|
properties = {}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var params = { |
|
|
|
|
|
|
|
|
const params = { |
|
|
body: { |
|
|
body: { |
|
|
type: type, |
|
|
type: type, |
|
|
query: query |
|
|
query: query |
|
|
@ -66,8 +66,8 @@ function create(type, query, properties, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -83,7 +83,7 @@ function get(monitorId, groupStates, callback){ |
|
|
groupStates = undefined; |
|
|
groupStates = undefined; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var params = {}; |
|
|
|
|
|
|
|
|
const params = {}; |
|
|
if(groupStates){ |
|
|
if(groupStates){ |
|
|
params.query = { |
|
|
params.query = { |
|
|
group_states: groupStates.join(",") |
|
|
group_states: groupStates.join(",") |
|
|
@ -104,8 +104,8 @@ function get(monitorId, groupStates, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -120,7 +120,7 @@ function getAll(options, callback){ |
|
|
callback = options; |
|
|
callback = options; |
|
|
options = {}; |
|
|
options = {}; |
|
|
} |
|
|
} |
|
|
var params = {}; |
|
|
|
|
|
|
|
|
const params = {}; |
|
|
if(typeof options === "object"){ |
|
|
if(typeof options === "object"){ |
|
|
params.query = {}; |
|
|
params.query = {}; |
|
|
if(options.group_states){ |
|
|
if(options.group_states){ |
|
|
@ -150,13 +150,13 @@ function getAll(options, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
* dogapi.initialize(options); |
|
|
* dogapi.initialize(options); |
|
|
* var query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100"; |
|
|
|
|
|
|
|
|
* const query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100"; |
|
|
* dogapi.monitor.update(1234, query, function(err, res){ |
|
|
* dogapi.monitor.update(1234, query, function(err, res){ |
|
|
* console.dir(res); |
|
|
* console.dir(res); |
|
|
* }); |
|
|
* }); |
|
|
@ -168,7 +168,7 @@ function update(monitorId, query, properties, callback){ |
|
|
properties = {}; |
|
|
properties = {}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var params = { |
|
|
|
|
|
|
|
|
const params = { |
|
|
body: { |
|
|
body: { |
|
|
query: query |
|
|
query: query |
|
|
} |
|
|
} |
|
|
@ -198,8 +198,8 @@ function update(monitorId, query, properties, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -224,8 +224,8 @@ function remove(monitorId, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -240,7 +240,7 @@ function mute(monitorId, options, callback){ |
|
|
callback = options; |
|
|
callback = options; |
|
|
options = {}; |
|
|
options = {}; |
|
|
} |
|
|
} |
|
|
var params = {}; |
|
|
|
|
|
|
|
|
const params = {}; |
|
|
if(typeof options === "object"){ |
|
|
if(typeof options === "object"){ |
|
|
params.body = {}; |
|
|
params.body = {}; |
|
|
if(options.scope){ |
|
|
if(options.scope){ |
|
|
@ -261,8 +261,8 @@ function mute(monitorId, options, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -284,8 +284,8 @@ function muteAll(callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -300,7 +300,7 @@ function unmute(monitorId, scope, callback){ |
|
|
callback = scope; |
|
|
callback = scope; |
|
|
scope = undefined; |
|
|
scope = undefined; |
|
|
} |
|
|
} |
|
|
var params = {}; |
|
|
|
|
|
|
|
|
const params = {}; |
|
|
if(scope){ |
|
|
if(scope){ |
|
|
params.body = { |
|
|
params.body = { |
|
|
scope: scope |
|
|
scope: scope |
|
|
@ -317,8 +317,8 @@ function unmute(monitorId, scope, callback){ |
|
|
* callback: function(err, res) |
|
|
* callback: function(err, res) |
|
|
*example: | |
|
|
*example: | |
|
|
* ```javascript
|
|
|
* ```javascript
|
|
|
* var dogapi = require("dogapi"); |
|
|
|
|
|
* var options = { |
|
|
|
|
|
|
|
|
* const dogapi = require("dogapi"); |
|
|
|
|
|
* const options = { |
|
|
* api_key: "api_key", |
|
|
* api_key: "api_key", |
|
|
* app_key: "app_key" |
|
|
* app_key: "app_key" |
|
|
* }; |
|
|
* }; |
|
|
@ -379,24 +379,24 @@ module.exports = { |
|
|
]; |
|
|
]; |
|
|
}, |
|
|
}, |
|
|
handleCli: function(subcommand, args, callback){ |
|
|
handleCli: function(subcommand, args, callback){ |
|
|
var states = []; |
|
|
|
|
|
|
|
|
const states = []; |
|
|
if(args["states"]){ |
|
|
if(args["states"]){ |
|
|
states = args["states"].split(","); |
|
|
states = args["states"].split(","); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var tags = []; |
|
|
|
|
|
|
|
|
const tags = []; |
|
|
if(args["tags"]){ |
|
|
if(args["tags"]){ |
|
|
tags = args["tags"].split(","); |
|
|
tags = args["tags"].split(","); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var name = args["name"]; |
|
|
|
|
|
var message = args["message"]; |
|
|
|
|
|
|
|
|
const name = args["name"]; |
|
|
|
|
|
const message = args["message"]; |
|
|
|
|
|
|
|
|
if(subcommand === "get"){ |
|
|
if(subcommand === "get"){ |
|
|
var monitorId = args._[4]; |
|
|
|
|
|
|
|
|
const monitorId = args._[4]; |
|
|
get(monitorId, states, callback); |
|
|
get(monitorId, states, callback); |
|
|
} else if(subcommand === "getall"){ |
|
|
} else if(subcommand === "getall"){ |
|
|
var options = {}; |
|
|
|
|
|
|
|
|
const options = {}; |
|
|
if(states.length){ |
|
|
if(states.length){ |
|
|
options.group_states = states; |
|
|
options.group_states = states; |
|
|
} |
|
|
} |
|
|
@ -405,8 +405,8 @@ module.exports = { |
|
|
} |
|
|
} |
|
|
getAll(options, callback); |
|
|
getAll(options, callback); |
|
|
} else if(subcommand === "mute"){ |
|
|
} else if(subcommand === "mute"){ |
|
|
var monitorId = args._[4]; |
|
|
|
|
|
var options = {}; |
|
|
|
|
|
|
|
|
const monitorId = args._[4]; |
|
|
|
|
|
const options = {}; |
|
|
if(args["scope"]){ |
|
|
if(args["scope"]){ |
|
|
options.scope = args["scope"]; |
|
|
options.scope = args["scope"]; |
|
|
} |
|
|
} |
|
|
@ -415,20 +415,20 @@ module.exports = { |
|
|
} |
|
|
} |
|
|
mute(monitorId, options, callback); |
|
|
mute(monitorId, options, callback); |
|
|
} else if(subcommand === "unmute"){ |
|
|
} else if(subcommand === "unmute"){ |
|
|
var monitorId = args._[4]; |
|
|
|
|
|
var scope = args["scope"]; |
|
|
|
|
|
|
|
|
const monitorId = args._[4]; |
|
|
|
|
|
const scope = args["scope"]; |
|
|
unmute(monitorId, scope, callback); |
|
|
unmute(monitorId, scope, callback); |
|
|
} else if(subcommand === "unmuteall"){ |
|
|
} else if(subcommand === "unmuteall"){ |
|
|
unmuteAll(callback); |
|
|
unmuteAll(callback); |
|
|
} else if(subcommand === "muteall"){ |
|
|
} else if(subcommand === "muteall"){ |
|
|
muteAll(callback); |
|
|
muteAll(callback); |
|
|
} else if(subcommand === "remove"){ |
|
|
} else if(subcommand === "remove"){ |
|
|
var monitorId = args._[4]; |
|
|
|
|
|
|
|
|
const monitorId = args._[4]; |
|
|
remove(monitorId, callback); |
|
|
remove(monitorId, callback); |
|
|
} else if(subcommand === "create" && args._.length > 5){ |
|
|
} else if(subcommand === "create" && args._.length > 5){ |
|
|
var type = args._[4]; |
|
|
|
|
|
var query = args._[5]; |
|
|
|
|
|
var properties = {}; |
|
|
|
|
|
|
|
|
const type = args._[4]; |
|
|
|
|
|
const query = args._[5]; |
|
|
|
|
|
const properties = {}; |
|
|
if(name){ |
|
|
if(name){ |
|
|
properties.name = name; |
|
|
properties.name = name; |
|
|
} |
|
|
} |
|
|
@ -437,9 +437,9 @@ module.exports = { |
|
|
} |
|
|
} |
|
|
create(type, query, properties, callback); |
|
|
create(type, query, properties, callback); |
|
|
} else if(subcommand === "update" && args._.length > 5){ |
|
|
} else if(subcommand === "update" && args._.length > 5){ |
|
|
var monitorId = args._[4]; |
|
|
|
|
|
var query = args._[5]; |
|
|
|
|
|
var properties = {}; |
|
|
|
|
|
|
|
|
const monitorId = args._[4]; |
|
|
|
|
|
const query = args._[5]; |
|
|
|
|
|
const properties = {}; |
|
|
if(name){ |
|
|
if(name){ |
|
|
properties.name = name; |
|
|
properties.name = name; |
|
|
} |
|
|
} |
|
|
|