mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Initial graphite tags support (#9239)
* graphite: initial seriesByTag() support * graphite: groupByTags() function * graphite: aliasByTags() function * graphite: fix optional params update, issue #9238 * graphite: fix tag-related functions version * graphite: add 1.1.x version to config * graphite: fix seriesByTag() series parsing
This commit is contained in:
committed by
Torkel Ödegaard
parent
4326790bb4
commit
f8b8907cc4
@@ -16,6 +16,7 @@ export class GraphiteConfigCtrl {
|
||||
graphiteVersions = [
|
||||
{name: '0.9.x', value: '0.9'},
|
||||
{name: '1.0.x', value: '1.0'},
|
||||
{name: '1.1.x', value: '1.1'},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -822,6 +822,49 @@ function (_, $) {
|
||||
version: '1.0'
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'seriesByTag',
|
||||
category: categories.Special,
|
||||
params: [
|
||||
{ name: "tagExpression", type: "string" },
|
||||
{ name: "tagExpression", type: "string", optional: true },
|
||||
{ name: "tagExpression", type: "string", optional: true },
|
||||
{ name: "tagExpression", type: "string", optional: true },
|
||||
],
|
||||
version: '1.1'
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: "groupByTags",
|
||||
category: categories.Special,
|
||||
params: [
|
||||
{
|
||||
name: "function",
|
||||
type: "string",
|
||||
options: ['sum', 'avg', 'maxSeries']
|
||||
},
|
||||
{ name: "tag", type: "string" },
|
||||
{ name: "tag", type: "string", optional: true },
|
||||
{ name: "tag", type: "string", optional: true },
|
||||
{ name: "tag", type: "string", optional: true },
|
||||
],
|
||||
defaultParams: ["sum", "tag"],
|
||||
version: '1.1'
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: "aliasByTags",
|
||||
category: categories.Special,
|
||||
params: [
|
||||
{ name: "tag", type: "string" },
|
||||
{ name: "tag", type: "string", optional: true },
|
||||
{ name: "tag", type: "string", optional: true },
|
||||
{ name: "tag", type: "string", optional: true },
|
||||
],
|
||||
defaultParams: ["tag"],
|
||||
version: '1.1'
|
||||
});
|
||||
|
||||
_.each(categories, function(funcList, catName) {
|
||||
categories[catName] = _.sortBy(funcList, 'name');
|
||||
});
|
||||
@@ -873,7 +916,7 @@ function (_, $) {
|
||||
// if string contains ',' and next param is optional, split and update both
|
||||
if (this._hasMultipleParamsInString(strValue, index)) {
|
||||
_.each(strValue.split(','), function(partVal, idx) {
|
||||
this.updateParam(partVal.trim(), idx);
|
||||
this.updateParam(partVal.trim(), index + idx);
|
||||
}.bind(this));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,8 @@ export class GraphiteQueryCtrl extends QueryCtrl {
|
||||
if ((index-1) >= func.def.params.length) {
|
||||
throw { message: 'invalid number of parameters to method ' + func.def.name };
|
||||
}
|
||||
this.addFunctionParameter(func, astNode.value, index, true);
|
||||
var shiftBack = this.isShiftParamsBack(func);
|
||||
this.addFunctionParameter(func, astNode.value, index, shiftBack);
|
||||
break;
|
||||
case 'metric':
|
||||
if (this.segments.length > 0) {
|
||||
@@ -113,6 +114,10 @@ export class GraphiteQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
isShiftParamsBack(func) {
|
||||
return func.def.name !== 'seriesByTag';
|
||||
}
|
||||
|
||||
getSegmentPathUpTo(index) {
|
||||
var arr = this.segments.slice(0, index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user