Skip to content

Commit

Permalink
InfluxDB: Interpolate tag keys in influxql queries (#79288)
Browse files Browse the repository at this point in the history
* interpolate tag keys

* fix unit tests
  • Loading branch information
itsmylife committed Dec 11, 2023
1 parent 488d487 commit 12793bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion public/app/plugins/datasource/influxdb/datasource.test.ts
Expand Up @@ -285,7 +285,7 @@ describe('InfluxDataSource Frontend Mode', () => {
const ds = new InfluxDatasource(getMockDSInstanceSettings(), templateSrv);

function influxChecks(query: InfluxQuery) {
expect(templateSrv.replace).toBeCalledTimes(11);
expect(templateSrv.replace).toBeCalledTimes(12);
expect(query.alias).toBe(text);
expect(query.measurement).toBe(textWithFormatRegex);
expect(query.policy).toBe(textWithFormatRegex);
Expand Down
1 change: 1 addition & 0 deletions public/app/plugins/datasource/influxdb/datasource.ts
Expand Up @@ -256,6 +256,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
expandedQuery.tags = query.tags.map((tag) => {
return {
...tag,
key: this.templateSrv.replace(tag.key, scopedVars, this.interpolateQueryExpr),
value: this.templateSrv.replace(tag.value, scopedVars, this.interpolateQueryExpr),
};
});
Expand Down
Expand Up @@ -176,7 +176,7 @@ describe('InfluxDataSource Backend Mode', () => {
const ds = new InfluxDatasource(getMockDSInstanceSettings(), templateSrv);

function influxChecks(query: InfluxQuery) {
expect(templateSrv.replace).toBeCalledTimes(11);
expect(templateSrv.replace).toBeCalledTimes(12);
expect(query.alias).toBe(text);
expect(query.measurement).toBe(textWithFormatRegex);
expect(query.policy).toBe(textWithFormatRegex);
Expand Down

0 comments on commit 12793bf

Please sign in to comment.