Skip to content

Commit

Permalink
Explore/Loki: Escape \ in labels for show context queries (grafana#26116
Browse files Browse the repository at this point in the history
)

* Hot fix, keep the file

* Add comment

* Update public/app/plugins/datasource/loki/datasource.ts

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Remove script.go file

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
ivanahuckova and aknuds1 committed Jul 7, 2020
1 parent 74b2c2a commit 52f12d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion public/app/plugins/datasource/loki/datasource.ts
Expand Up @@ -409,7 +409,7 @@ export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {

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
Expand Down

0 comments on commit 52f12d1

Please sign in to comment.