diff --git a/pkg/tsdb/loki/loki.go b/pkg/tsdb/loki/loki.go index 976c1db464d..67d5b8b6c8d 100644 --- a/pkg/tsdb/loki/loki.go +++ b/pkg/tsdb/loki/loki.go @@ -98,7 +98,7 @@ func (s *Service) CallResource(ctx context.Context, req *backend.CallResourceReq if req.Method != "GET" { return fmt.Errorf("invalid resource method: %s", req.Method) } - if (!strings.HasPrefix(url, "/loki/api/v1/label?")) && + if (!strings.HasPrefix(url, "/loki/api/v1/labels?")) && (!strings.HasPrefix(url, "/loki/api/v1/label/")) && // the `/label/$label_name/values` form (!strings.HasPrefix(url, "/loki/api/v1/series?")) { return fmt.Errorf("invalid resource URL: %s", url) diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 79b808543aa..9bae8fc4890 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -441,10 +441,10 @@ export class LokiDatasource async metadataRequest(url: string, params?: Record) { if (config.featureToggles.lokiBackendMode) { const res = await this.getResource(url, params); - return res.data || res.values || []; + return res.data || []; } else { const res = await lastValueFrom(this._request(url, params, { hideFromInspector: true })); - return res.data.data || res.data.values || []; + return res.data.data || []; } } @@ -479,7 +479,7 @@ export class LokiDatasource } async labelNamesQuery() { - const url = `${LOKI_ENDPOINT}/label`; + const url = `${LOKI_ENDPOINT}/labels`; const params = this.getTimeRangeParams(); const result = await this.metadataRequest(url, params); return result.map((value: string) => ({ text: value })); diff --git a/public/app/plugins/datasource/loki/language_provider.test.ts b/public/app/plugins/datasource/loki/language_provider.test.ts index 168d696855e..194f388ef00 100644 --- a/public/app/plugins/datasource/loki/language_provider.test.ts +++ b/public/app/plugins/datasource/loki/language_provider.test.ts @@ -259,7 +259,7 @@ describe('Request URL', () => { const instance = new LanguageProvider(datasourceWithLabels); instance.fetchLabels(); - const expectedUrl = '/loki/api/v1/label'; + const expectedUrl = '/loki/api/v1/labels'; expect(datasourceSpy).toHaveBeenCalledWith(expectedUrl, rangeParams); }); }); diff --git a/public/app/plugins/datasource/loki/language_provider.ts b/public/app/plugins/datasource/loki/language_provider.ts index 330df0562a2..9b5aeba208d 100644 --- a/public/app/plugins/datasource/loki/language_provider.ts +++ b/public/app/plugins/datasource/loki/language_provider.ts @@ -364,7 +364,7 @@ export default class LokiLanguageProvider extends LanguageProvider { * Fetches all label keys */ async fetchLabels(): Promise { - const url = '/loki/api/v1/label'; + const url = '/loki/api/v1/labels'; const timeRange = this.datasource.getTimeRangeParams(); this.labelFetchTs = Date.now().valueOf(); diff --git a/public/app/plugins/datasource/loki/mocks.ts b/public/app/plugins/datasource/loki/mocks.ts index 9d5e7b0ca44..4fb4b50dbf3 100644 --- a/public/app/plugins/datasource/loki/mocks.ts +++ b/public/app/plugins/datasource/loki/mocks.ts @@ -21,7 +21,7 @@ export function makeMockLokiDatasource(labelsAndValues: Labels, series?: SeriesF const lokiLabelsAndValuesEndpointRegex = /^\/loki\/api\/v1\/label\/(\w*)\/values/; const lokiSeriesEndpointRegex = /^\/loki\/api\/v1\/series/; - const lokiLabelsEndpoint = `${LOKI_ENDPOINT}/label`; + const lokiLabelsEndpoint = `${LOKI_ENDPOINT}/labels`; const rangeMock = { start: 1560153109000, end: 1560163909000,