Commit e2dd201e by Torkel Ödegaard

Fixes #13 (partially) Use relative time ranges whenever possible when querying graphite

parent f0c8b70f
...@@ -320,7 +320,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -320,7 +320,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.updateTimeRange(); $scope.updateTimeRange();
var graphiteQuery = { var graphiteQuery = {
range: $scope.range, range: filterSrv.timeRange(false),
targets: $scope.panel.targets, targets: $scope.panel.targets,
maxDataPoints: $scope.panel.span * 50 maxDataPoints: $scope.panel.span * 50
}; };
......
...@@ -14,8 +14,8 @@ function (angular, _, $, config) { ...@@ -14,8 +14,8 @@ function (angular, _, $, config) {
this.query = function(options) { this.query = function(options) {
try { try {
var graphOptions = { var graphOptions = {
from: $.plot.formatDate(options.range.from, '%H%:%M_%Y%m%d'), from: this.translateTime(options.range.from),
until: $.plot.formatDate(options.range.to, '%H%:%M_%Y%m%d'), until: this.translateTime(options.range.to),
targets: options.targets, targets: options.targets,
maxDataPoints: options.maxDataPoints maxDataPoints: options.maxDataPoints
}; };
...@@ -34,6 +34,22 @@ function (angular, _, $, config) { ...@@ -34,6 +34,22 @@ function (angular, _, $, config) {
} }
}; };
this.translateTime = function(date) {
if (_.isDate(date)) {
return $.plot.formatDate(date, '%H%:%M_%Y%m%d');
}
if (date === 'now') {
return 'now';
}
date = date.substring(3);
date = date.replace('m', 'min');
date = date.replace('M', 'mon');
return date;
};
this.match = function(targets, graphiteTargetStr) { this.match = function(targets, graphiteTargetStr) {
var found = targets[0]; var found = targets[0];
......
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