mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: do not use the old labels-api (#48185)
* loki: do not use old labels-api * adjust allowed-url-list * fixed tests
This commit is contained in:
@@ -441,10 +441,10 @@ export class LokiDatasource
|
||||
async metadataRequest(url: string, params?: Record<string, string | number>) {
|
||||
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 }));
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -364,7 +364,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
|
||||
* Fetches all label keys
|
||||
*/
|
||||
async fetchLabels(): Promise<string[]> {
|
||||
const url = '/loki/api/v1/label';
|
||||
const url = '/loki/api/v1/labels';
|
||||
const timeRange = this.datasource.getTimeRangeParams();
|
||||
this.labelFetchTs = Date.now().valueOf();
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user