From 461fc94103b58e798cb89321f1542312c6e6e026 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 (cherry picked from commit 52f12d10c5df97873c2fb09afb0cc571ff4b2cd3) --- 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 86e51c80262..da08c910409 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -387,7 +387,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