diff --git a/app/components/service/service.html b/app/components/service/service.html
index 0c55695..cfa6191 100644
--- a/app/components/service/service.html
+++ b/app/components/service/service.html
@@ -6,6 +6,8 @@
+
+
diff --git a/app/components/service/service.js b/app/components/service/service.js
index 5b9f9b0..e67b4e3 100644
--- a/app/components/service/service.js
+++ b/app/components/service/service.js
@@ -5,6 +5,7 @@ angular.module('bansho.service', ['bansho.surveil',
'bansho.service.live',
'bansho.service.info',
'bansho.service.metrics',
+ 'bansho.service.graphs',
'bansho.table.state_icon'])
.value('serviceConfig', {})
diff --git a/app/components/service/service_graphs/service_graphs.html b/app/components/service/service_graphs/service_graphs.html
new file mode 100644
index 0000000..6c56f51
--- /dev/null
+++ b/app/components/service/service_graphs/service_graphs.html
@@ -0,0 +1,6 @@
+
+
Graph - {{metric}}
+
+
+
diff --git a/app/components/service/service_graphs/service_graphs.js b/app/components/service/service_graphs/service_graphs.js
new file mode 100644
index 0000000..001c0a1
--- /dev/null
+++ b/app/components/service/service_graphs/service_graphs.js
@@ -0,0 +1,28 @@
+'use strict';
+
+angular.module('bansho.service.graphs', [])
+
+ .controller('ServiceGraphsCtrl', ['$scope', 'surveilStatus', 'iframeUrl', function ($scope, surveilStatus, iframeUrl) {
+ $scope.$watch('service', function(service) {
+ if (service) {
+ surveilStatus.getServiceMetricNames(service.host_name, service.service_description).then(function(metric_names){
+ $scope.iframeUrls = {};
+ angular.forEach(metric_names, function (metric) {
+ var metricName = metric.metric_name.substr(7);
+ $scope.iframeUrls[metricName] = iframeUrl.getIFrameUrl(metric.metric_name, service.host_name, service.service_description);
+ })
+ })
+ }
+ })
+ }])
+
+ .directive('banshoServiceGraphs', ['iframeUrl', function (iframeUrl) {
+ return {
+ restrict: 'E',
+ scope: {
+ service: '=service'
+ },
+ controller: 'ServiceGraphsCtrl',
+ templateUrl: 'components/service/service_graphs/service_graphs.html'
+ };
+ }]);
diff --git a/app/components/surveil/status.js b/app/components/surveil/status.js
index 0bd1da5..68b4339 100644
--- a/app/components/surveil/status.js
+++ b/app/components/surveil/status.js
@@ -64,6 +64,33 @@ angular.module('bansho.surveil')
return responsePromise.promise;
};
+ var getMetricNames = function (host, service) {
+ var url = '/surveil/v2/status/hosts/' + host,
+ responsePromise = $q.defer();
+
+ if (service !== undefined) {
+ url += '/services/' + service;
+ }
+
+ url += '/metrics/';
+
+ $http.get(url).success(function (metrics) {
+ var result = [];
+ for (var i = 0; i < metrics.length; i += 1) {
+ if (metrics[i].metric_name.indexOf("metric_") === 0) {
+ result.push(metrics[i]);
+ }
+ }
+
+ responsePromise.resolve(result);
+ })
+ .error(function () {
+ throw new Error('getMetricNames: GET Request failed');
+ });
+
+ return responsePromise.promise;
+ };
+
var getService = function (hostName, description) {
var fields = [],
filters = {
@@ -220,10 +247,18 @@ angular.module('bansho.surveil')
return getMetric(host, undefined, metric);
};
+ var getHostMetricNames = function (host, metric) {
+ return getMetricNames(host, undefined);
+ };
+
var getServiceMetric = function (host, service, metric) {
return getMetric(host, service, metric);
};
+ var getServiceMetricNames = function (host, service) {
+ return getMetricNames(host, service);
+ };
+
var hostQueryTransform = function (fields, filters) {
var i,
transformations = {
@@ -381,6 +416,8 @@ angular.module('bansho.surveil')
getTotalServices: getTotalServices,
getServicesByHost: getServicesByHost,
getHostMetric: getHostMetric,
- getServiceMetric: getServiceMetric
+ getHostMetricNames: getHostMetricNames,
+ getServiceMetric: getServiceMetric,
+ getServiceMetricNames: getServiceMetricNames
};
}]);
diff --git a/app/index.html b/app/index.html
index 3c50701..e88ffda 100644
--- a/app/index.html
+++ b/app/index.html
@@ -84,6 +84,7 @@
+