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

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

* test for adding scopedVars to tags

(cherry picked from commit cd6b7ba688)

Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-09-15 10:05:41 -05:00
committed by GitHub
co-authored by Brendan O'Handley
parent f500459303
commit 131b857bd2
2 changed files with 14 additions and 1 deletions
@@ -465,7 +465,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'),
};
});
}
@@ -298,6 +298,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);
});
});
});
});