From c86bdb400018da926a37d0c2064eea636e5a7ed1 Mon Sep 17 00:00:00 2001 From: Rahman Date: Wed, 19 Apr 2017 16:20:58 +0800 Subject: [PATCH 1/3] supporting tags in updating a monitor --- lib/api/monitor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api/monitor.js b/lib/api/monitor.js index 44bfcbd..a1a632a 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -137,6 +137,7 @@ function getAll(options, callback){ * optional, an object containing any of the following * * name: the name of the monitor * * message: the message for the monitor + * * tags: a list of strings as tags to associate with the monitor * * options: an object, to see available options please see the [monitor create](http://docs.datadoghq.com/api/#monitor-create) docs * callback: function(err, res) *example: | @@ -172,6 +173,9 @@ function update(monitorId, query, properties, callback){ if(properties.message){ params.body.message = properties.message; } + if(properties.tags){ + params.body.tags = properties.tags; + } if(typeof properties.options === "object"){ params.body.options = properties.options; } From f39ae1ec58fac17eba99c66248508574857cbf54 Mon Sep 17 00:00:00 2001 From: Rahman Date: Wed, 19 Apr 2017 16:23:40 +0800 Subject: [PATCH 2/3] Add tag support upon monitor creation --- lib/api/monitor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api/monitor.js b/lib/api/monitor.js index a1a632a..adfaebf 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -10,6 +10,7 @@ var util = require("util"); * optional, an object containing any of the following * * name: the name of the monitor * * message: the message for the monitor + * * tags: a list of strings as tags to associate with the monitor * * options: an object, to see available options please see the [monitor create](http://docs.datadoghq.com/api/#monitor-create) docs * callback: function(err, res) *example: | @@ -47,6 +48,9 @@ function create(type, query, properties, callback){ if(properties.message){ params.body.message = properties.message; } + if(properties.tags){ + params.body.tags = properties.tags; + } if(typeof properties.options === "object"){ params.body.options = properties.options; } From 24fabce46542a60d2d50916da9db4341c4d35ad7 Mon Sep 17 00:00:00 2001 From: Rahman Date: Wed, 19 Apr 2017 18:24:04 +0800 Subject: [PATCH 3/3] Filter based on monitor tags when getting all monitors --- lib/api/monitor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api/monitor.js b/lib/api/monitor.js index adfaebf..d506891 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -100,6 +100,7 @@ function get(monitorId, groupStates, callback){ * optional, an object containing any of the following * * group_states: an array containing any of the following "all", "alert", "warn", or "no data" * * tags: an array of "tag:value"'s to filter on + * * monitor_tags: a comma separated list indicating what service and/or custom tags * callback: function(err, res) *example: | * ```javascript @@ -128,6 +129,9 @@ function getAll(options, callback){ if(options.tags){ params.query.tags = options.tags.join(","); } + if(options.monitor_tags){ + params.query.monitor_tags = options.monitor_tags.join(","); + } } client.request("GET", "/monitor", params, callback); }