mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix Loki with repeated panels and interpolation for Explore (#21685)
This commit is contained in:
@@ -2,6 +2,7 @@ import _ from 'lodash';
|
||||
import ResponseParser from './response_parser';
|
||||
import MysqlQuery from 'app/plugins/datasource/mysql/mysql_query';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { ScopedVars } from '@grafana/data';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
//Types
|
||||
@@ -27,7 +28,8 @@ export class MysqlDatasource {
|
||||
interpolateVariable = (value: string, variable: any) => {
|
||||
if (typeof value === 'string') {
|
||||
if (variable.multi || variable.includeAll) {
|
||||
return this.queryModel.quoteLiteral(value);
|
||||
const result = this.queryModel.quoteLiteral(value);
|
||||
return result;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
@@ -43,14 +45,17 @@ export class MysqlDatasource {
|
||||
return quotedValues.join(',');
|
||||
};
|
||||
|
||||
interpolateVariablesInQueries(queries: MysqlQueryForInterpolation[]): MysqlQueryForInterpolation[] {
|
||||
interpolateVariablesInQueries(
|
||||
queries: MysqlQueryForInterpolation[],
|
||||
scopedVars: ScopedVars
|
||||
): MysqlQueryForInterpolation[] {
|
||||
let expandedQueries = queries;
|
||||
if (queries && queries.length > 0) {
|
||||
expandedQueries = queries.map(query => {
|
||||
const expandedQuery = {
|
||||
...query,
|
||||
datasource: this.name,
|
||||
rawSql: this.templateSrv.replace(query.rawSql, {}, this.interpolateVariable),
|
||||
rawSql: this.templateSrv.replace(query.rawSql, scopedVars, this.interpolateVariable),
|
||||
};
|
||||
return expandedQuery;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user