From 52f12d10c5df97873c2fb09afb0cc571ff4b2cd3 Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Tue, 7 Jul 2020 17:42:49 +0200 Subject: [PATCH] Explore/Loki: Escape \ in labels for show context queries (#26116) * Hot fix, keep the file * Add comment * Update public/app/plugins/datasource/loki/datasource.ts Co-authored-by: Arve Knudsen * Remove script.go file Co-authored-by: Arve Knudsen --- public/app/plugins/datasource/loki/datasource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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