Merge remote-tracking branch 'origin/master' into triggers-panel
This commit is contained in:
@@ -128,7 +128,7 @@ timeShift(interval)
|
|||||||
Draws the selected metrics shifted in time. If no sign is given, a minus sign ( - ) is implied which will shift the metric back in time. If a plus sign ( + ) is given, the metric will be shifted forward in time.
|
Draws the selected metrics shifted in time. If no sign is given, a minus sign ( - ) is implied which will shift the metric back in time. If a plus sign ( + ) is given, the metric will be shifted forward in time.
|
||||||
Examples:
|
Examples:
|
||||||
```
|
```
|
||||||
timeShift(24h) - shift metric back in 2h hours
|
timeShift(24h) - shift metric back in 24h hours
|
||||||
timeShift(-24h) - the same result as for timeShift(24h)
|
timeShift(-24h) - the same result as for timeShift(24h)
|
||||||
timeShift(+1d) - shift metric forward in 1 day
|
timeShift(+1d) - shift metric forward in 1 day
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -156,6 +156,18 @@ function setAlias(alias, timeseries) {
|
|||||||
return timeseries;
|
return timeseries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setAliasByRegex(alias, timeseries) {
|
||||||
|
timeseries.target = extractText(timeseries.target, alias);
|
||||||
|
return timeseries;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractText(str, pattern) {
|
||||||
|
var extractPattern = new RegExp(pattern);
|
||||||
|
var extractedValue = extractPattern.exec(str);
|
||||||
|
extractedValue = extractedValue[0]
|
||||||
|
return extractedValue;
|
||||||
|
}
|
||||||
|
|
||||||
function scale(factor, datapoints) {
|
function scale(factor, datapoints) {
|
||||||
return _.map(datapoints, point => {
|
return _.map(datapoints, point => {
|
||||||
return [
|
return [
|
||||||
@@ -281,7 +293,8 @@ let metricFunctions = {
|
|||||||
top: _.partial(limit, 'top'),
|
top: _.partial(limit, 'top'),
|
||||||
bottom: _.partial(limit, 'bottom'),
|
bottom: _.partial(limit, 'bottom'),
|
||||||
timeShift: timeShift,
|
timeShift: timeShift,
|
||||||
setAlias: setAlias
|
setAlias: setAlias,
|
||||||
|
setAliasByRegex: setAliasByRegex
|
||||||
};
|
};
|
||||||
|
|
||||||
let aggregationFunctions = {
|
let aggregationFunctions = {
|
||||||
|
|||||||
@@ -149,13 +149,24 @@ addFuncDef({
|
|||||||
defaultParams: ['24h'],
|
defaultParams: ['24h'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Alias
|
||||||
|
|
||||||
addFuncDef({
|
addFuncDef({
|
||||||
name: 'setAlias',
|
name: 'setAlias',
|
||||||
category: 'Alias',
|
category: 'Alias',
|
||||||
params: [
|
params: [
|
||||||
{ name: 'alias', type: 'string'}
|
{ name: 'alias', type: 'string' }
|
||||||
],
|
],
|
||||||
defaultParams: [],
|
defaultParams: []
|
||||||
|
});
|
||||||
|
|
||||||
|
addFuncDef({
|
||||||
|
name: 'setAliasByRegex',
|
||||||
|
category: 'Alias',
|
||||||
|
params: [
|
||||||
|
{ name: 'aliasByRegex', type: 'string' }
|
||||||
|
],
|
||||||
|
defaultParams: []
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(categories, function(funcList, catName) {
|
_.each(categories, function(funcList, catName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user