InfluxDB: add scopedVars to tags to fix repeated panels querying all selected variables (#54934)

* add scoped vars for tags in influx to fix repeated panels

* test for adding scopedVars to tags
This commit is contained in:
Brendan O'Handley 2022-09-15 09:29:19 -05:00 committed by GitHub
parent 92857ef331
commit cd6b7ba688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -499,7 +499,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
expandedQuery.tags = query.tags.map((tag) => {
return {
...tag,
value: this.templateSrv.replace(tag.value, undefined, 'regex'),
value: this.templateSrv.replace(tag.value, scopedVars, 'regex'),
};
});
}

View File

@ -319,6 +319,19 @@ describe('InfluxDataSource', () => {
});
influxChecks(query);
});
it('should apply all scopedVars to tags', () => {
ds.isFlux = false;
ds.access = 'proxy';
config.featureToggles.influxdbBackendMigration = true;
const query = ds.applyTemplateVariables(influxQuery, {
interpolationVar: { text: text, value: text },
interpolationVar2: { text: 'interpolationText2', value: 'interpolationText2' },
});
const value = query.tags[0].value;
const scopedVars = 'interpolationText|interpolationText2';
expect(value).toBe(scopedVars);
});
});
});
});