The regex values were not being applied to numbers. (Grafana 4.4.3 - Graphite Datasource) - I was unable to find a suitable way of getting graphite to round its values (perhaps there is one that I'm unaware of). But In any case, I feel the behavior of the valuedisplayregex is improved by having it also support numerical values.
I modified dist/status_ctrl.js as follows to achieve the desired result: (I don't typically code in javascript - I didn't submit it as a patch as I suspect you may wish to alter significantly)
It uses the original filter for number in the cases where regex fails.
coreModule.filter('numberOrTextWithRegex', function () {
var numberOrTextFilter = function numberOrTextFilter(input, textRegex) {
var stringInput;
var failReturn;
if (angular.isNumber(input)) {
stringInput = input.toString();
failReturn = _this2.filter('number')(input);
} else {
stringInput = input;
failReturn = input;
}
if (textRegex == null || textRegex.length == 0) {
return failReturn;
} else {
var regex = void 0;
try {
regex = new RegExp(textRegex);
} catch (e) {
return failReturn;
}
var matchResults = stringInput.match(regex);
if (matchResults == null) {
return failReturn;
} else {
return matchResults[0];
}
}
};
The regex values were not being applied to numbers. (Grafana 4.4.3 - Graphite Datasource) - I was unable to find a suitable way of getting graphite to round its values (perhaps there is one that I'm unaware of). But In any case, I feel the behavior of the valuedisplayregex is improved by having it also support numerical values.
I modified dist/status_ctrl.js as follows to achieve the desired result: (I don't typically code in javascript - I didn't submit it as a patch as I suspect you may wish to alter significantly)
It uses the original filter for number in the cases where regex fails.