mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Merge pull request #16111 from grafana/graphite-series-by-tag-issue
Graphite: Fixed issue with using series ref and series by tag
This commit is contained in:
commit
31dc3cfcf4
@ -98,7 +98,7 @@ export default class GraphiteQuery {
|
||||
this.functions.push(innerFunc);
|
||||
break;
|
||||
case 'series-ref':
|
||||
if (this.segments.length > 0) {
|
||||
if (this.segments.length > 0 || this.getSeriesByTagFuncIndex() >= 0) {
|
||||
this.addFunctionParameter(func, astNode.value);
|
||||
} else {
|
||||
this.segments.push(astNode);
|
||||
|
@ -44,4 +44,16 @@ describe('Graphite query model', () => {
|
||||
expect(ctx.queryModel.target.targetFull).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when query seriesByTag and series ref', () => {
|
||||
beforeEach(() => {
|
||||
ctx.target = { refId: 'A', target: `group(seriesByTag('namespace=asd'), #A)` };
|
||||
ctx.targets = [ctx.target];
|
||||
ctx.queryModel = new GraphiteQuery(ctx.datasource, ctx.target, ctx.templateSrv);
|
||||
});
|
||||
|
||||
it('should keep group function series ref', () => {
|
||||
expect(ctx.queryModel.functions[1].params[0]).toBe('#A');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -24,7 +24,6 @@ describe('GraphiteQueryCtrl', () => {
|
||||
beforeEach(() => {
|
||||
GraphiteQueryCtrl.prototype.target = ctx.target;
|
||||
GraphiteQueryCtrl.prototype.datasource = ctx.datasource;
|
||||
|
||||
GraphiteQueryCtrl.prototype.panelCtrl = ctx.panelCtrl;
|
||||
|
||||
ctx.ctrl = new GraphiteQueryCtrl(
|
||||
@ -84,22 +83,6 @@ describe('GraphiteQueryCtrl', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when initializing target without metric expression and only function', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ctrl.target.target = 'asPercent(#A, #B)';
|
||||
ctx.ctrl.datasource.metricFindQuery = () => Promise.resolve([]);
|
||||
ctx.ctrl.parseTarget();
|
||||
});
|
||||
|
||||
it('should not add select metric segment', () => {
|
||||
expect(ctx.ctrl.segments.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should add second series ref as param', () => {
|
||||
expect(ctx.ctrl.queryModel.functions[0].params.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when initializing a target with single param func using variable', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ctrl.target.target = 'movingAverage(prod.count, $var)';
|
||||
|
Loading…
Reference in New Issue
Block a user