From 92b5af8963e59b2373e093bf0d851dacfcf1a951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Tue, 26 May 2015 11:05:21 -0400 Subject: [PATCH] Added metrics query for host and service Change-Id: I781abebd8618ac8034934e6d315adb7635f10815 --- app/components/surveil/status.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/components/surveil/status.js b/app/components/surveil/status.js index 89e8569..f48be95 100644 --- a/app/components/surveil/status.js +++ b/app/components/surveil/status.js @@ -44,6 +44,25 @@ angular.module('bansho.surveil') }); }; + var getMetric = function (host, service, metric) { + var url = '/surveil/v2/status/hosts/' + host, + responsePromise = $q.defer(); + + if (service !== undefined) { + url += '/services/' + service; + } + + url += '/metrics/' + metric; + + $http.get(url).success(function (metric) { + responsePromise.resolve(metric); + }) + .error(function () { + throw new Error('getMetric: GET Request failed'); + }); + + return responsePromise.promise; + }; var getService = function (hostName, description) { var fields = [], @@ -197,6 +216,14 @@ angular.module('bansho.surveil') return responsePromise.promise; }; + var getHostMetric = function (host, metric) { + return getMetric(host, undefined, metric); + }; + + var getServiceMetric = function (host, service, metric) { + return getMetric(host, service, metric); + }; + var hostQueryTransform = function (fields, filters) { var i, transformations = { @@ -352,6 +379,8 @@ angular.module('bansho.surveil') getTableData: getTableData, getTotalHosts: getTotalHosts, getTotalServices: getTotalServices, - getServicesByHost: getServicesByHost + getServicesByHost: getServicesByHost, + getHostMetric: getHostMetric, + getServiceMetric: getServiceMetric }; }]);