From 2d5dc5d6b2e494f4eb929dffdf7f4086a17dba02 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2019 15:29:32 +0100 Subject: [PATCH] Loki: fix labels fetching when no initial range given (#21000) --- public/app/plugins/datasource/loki/language_provider.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/loki/language_provider.ts b/public/app/plugins/datasource/loki/language_provider.ts index efd2aaa62ec..331cae75e4f 100644 --- a/public/app/plugins/datasource/loki/language_provider.ts +++ b/public/app/plugins/datasource/loki/language_provider.ts @@ -324,8 +324,8 @@ export default class LokiLanguageProvider extends LanguageProvider { const url = '/api/prom/label'; try { this.logLabelFetchTs = Date.now(); - - const res = await this.request(url, rangeToParams(absoluteRange)); + const rangeParams = absoluteRange ? rangeToParams(absoluteRange) : {}; + const res = await this.request(url, rangeParams); const labelKeys = res.data.data.slice().sort(); this.labelKeys = { @@ -351,7 +351,8 @@ export default class LokiLanguageProvider extends LanguageProvider { async fetchLabelValues(key: string, absoluteRange: AbsoluteTimeRange) { const url = `/api/prom/label/${key}/values`; try { - const res = await this.request(url, rangeToParams(absoluteRange)); + const rangeParams = absoluteRange ? rangeToParams(absoluteRange) : {}; + const res = await this.request(url, rangeParams); const values = res.data.data.slice().sort(); // Add to label options