Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

use metric alias to find metrics instead of relying on target attribute #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/tasseo/public/j/tasseo.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ TasseoGraphiteDatasource.prototype = {
}).done(function(metricResults) {
_.each(metrics, function(metric, idx) {
var metricResult = _.find(metricResults, function(metricResult) {
return ('keepLastValue(' + metric.target + ')') == metricResult.target;
return ('keepLastValue(' + metric.alias + ')') == metricResult.target;
});
if(metricResult === undefined) {
console.log("not found: " + metric.alias);
Expand All @@ -225,10 +225,12 @@ TasseoGraphiteDatasource.prototype = {

urlForMetrics: function(metrics, period) {
var targets = _.map(metrics, function(metric) {
var wrap_alias = function(metric) { return "alias(" + encodeURI(metric.target) + ", '" + metric.alias + "')" ; };

if (this.options.padnulls) {
return 'target=keepLastValue(' + encodeURI(metric.target) + ')'
return 'target=keepLastValue(+' + wrap_alias(metric) + ')';
} else {
return 'target=' + encodeURI(metric.target)
return 'target=' + wrap_alias(metric);
}
}, this).join("&");

Expand Down