Commit 14f09e37 by Torkel Ödegaard

Added filtering support for graphite events/metrics, Closes #402

parent d2a342a9
......@@ -29,13 +29,11 @@ function (angular, $, kbn, _) {
this.loader = data.loader || {};
_.defaults(this.loader, {
save_gist: false,
save_elasticsearch: true,
save_default: true,
save_temp: true,
save_temp_ttl_enable: true,
save_temp_ttl: '30d',
load_gist: false,
load_elasticsearch: true,
hide: false
});
......
......@@ -40,7 +40,7 @@ define([
},
applyTemplateToTarget: function(target) {
if (target.indexOf('[[') === -1) {
if (!target || target.indexOf('[[') === -1) {
return target;
}
......
......@@ -63,9 +63,10 @@ function (angular, _, $, config, kbn, moment) {
GraphiteDatasource.prototype.annotationQuery = function(annotation, filterSrv, rangeUnparsed) {
// Graphite metric as annotation
if (annotation.target) {
var target = filterSrv.applyTemplateToTarget(annotation.target);
var graphiteQuery = {
range: rangeUnparsed,
targets: [{ target: annotation.target }],
targets: [{ target: target }],
format: 'json',
maxDataPoints: 100
};
......@@ -93,17 +94,19 @@ function (angular, _, $, config, kbn, moment) {
});
}
// Graphite event as annotation
else if (annotation.tags) {
return this.events({ range: rangeUnparsed, tags: annotation.tags })
else {
var tags = filterSrv.applyTemplateToTarget(annotation.tags);
return this.events({ range: rangeUnparsed, tags: tags })
.then(function(results) {
var list = [];
for (var i = 0; i < results.data; i++) {
for (var i = 0; i < results.data.length; i++) {
var e = results.data[i];
list.push({
annotation: annotation,
time: event.when * 1000,
title: event.what,
tags: event.tags,
text: event.data
time: e.when * 1000,
title: e.what,
tags: e.tags,
text: e.data
});
}
return list;
......
......@@ -22,7 +22,7 @@ function(angular, _, config) {
$timeout(function() {
self.original = angular.copy(newDashboard);
self.current = newDashboard;
}, 1000);
}, 1200);
});
$rootScope.$on("dashboard-saved", function(event, savedDashboard) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment