|
|
|
|
@ -439,13 +439,13 @@ 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 || []; |
|
|
|
|
} else { |
|
|
|
|
const res = await lastValueFrom(this._request(url, params, { hideFromInspector: true })); |
|
|
|
|
return res.data.data || []; |
|
|
|
|
// url must not start with a `/`, otherwise the AJAX-request
|
|
|
|
|
// going from the browser will contain `//`, which can cause problems.
|
|
|
|
|
if (url.startsWith('/')) { |
|
|
|
|
throw new Error(`invalid metadata request url: ${url}`); |
|
|
|
|
} |
|
|
|
|
const res = await this.getResource(url, params); |
|
|
|
|
return res.data || []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async metricFindQuery(query: string) { |
|
|
|
|
@ -479,7 +479,7 @@ export class LokiDatasource |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async labelNamesQuery() { |
|
|
|
|
const url = `${LOKI_ENDPOINT}/labels`; |
|
|
|
|
const url = 'labels'; |
|
|
|
|
const params = this.getTimeRangeParams(); |
|
|
|
|
const result = await this.metadataRequest(url, params); |
|
|
|
|
return result.map((value: string) => ({ text: value })); |
|
|
|
|
@ -487,7 +487,7 @@ export class LokiDatasource |
|
|
|
|
|
|
|
|
|
async labelValuesQuery(label: string) { |
|
|
|
|
const params = this.getTimeRangeParams(); |
|
|
|
|
const url = `${LOKI_ENDPOINT}/label/${label}/values`; |
|
|
|
|
const url = `label/${label}/values`; |
|
|
|
|
const result = await this.metadataRequest(url, params); |
|
|
|
|
return result.map((value: string) => ({ text: value })); |
|
|
|
|
} |
|
|
|
|
@ -498,7 +498,7 @@ export class LokiDatasource |
|
|
|
|
...timeParams, |
|
|
|
|
'match[]': expr, |
|
|
|
|
}; |
|
|
|
|
const url = `${LOKI_ENDPOINT}/series`; |
|
|
|
|
const url = 'series'; |
|
|
|
|
const streams = new Set(); |
|
|
|
|
const result = await this.metadataRequest(url, params); |
|
|
|
|
result.forEach((stream: { [key: string]: string }) => { |
|
|
|
|
|