diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 6afe8f939a8..efe87ff8537 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -409,7 +409,7 @@ export class LokiDatasource extends DataSourceApi { prepareLogRowContextQueryTarget = (row: LogRowModel, limit: number, direction: 'BACKWARD' | 'FORWARD') => { const query = Object.keys(row.labels) - .map(label => `${label}="${row.labels[label]}"`) + .map(label => `${label}="${row.labels[label].replace(/\\/g, '\\\\')}"`) // escape backslashes in label as users can't escape them by themselves .join(','); const contextTimeBuffer = 2 * 60 * 60 * 1000; // 2h buffer