mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
loki: add back frontend-mode metadata queries (#49297)
This commit is contained in:
parent
93e299305c
commit
0caeaaafe3
@ -1002,7 +1002,7 @@ describe('LokiDatasource', () => {
|
||||
describe('importing queries', () => {
|
||||
it('keeps all labels when no labels are loaded', async () => {
|
||||
const ds = createLokiDSForTests();
|
||||
ds.getResource = () => Promise.resolve({ data: [] });
|
||||
fetchMock.mockImplementation(() => of(createFetchResponse({ data: [] })));
|
||||
const queries = await ds.importFromAbstractQueries([
|
||||
{
|
||||
refId: 'A',
|
||||
@ -1017,9 +1017,7 @@ describe('LokiDatasource', () => {
|
||||
|
||||
it('filters out non existing labels', async () => {
|
||||
const ds = createLokiDSForTests();
|
||||
ds.getResource = () => {
|
||||
return Promise.resolve({ data: ['foo'] });
|
||||
};
|
||||
fetchMock.mockImplementation(() => of(createFetchResponse({ data: ['foo'] })));
|
||||
const queries = await ds.importFromAbstractQueries([
|
||||
{
|
||||
refId: 'A',
|
||||
|
@ -467,8 +467,15 @@ export class LokiDatasource
|
||||
if (url.startsWith('/')) {
|
||||
throw new Error(`invalid metadata request url: ${url}`);
|
||||
}
|
||||
const res = await this.getResource(url, params);
|
||||
return res.data || [];
|
||||
|
||||
if (this.useBackendMode) {
|
||||
const res = await this.getResource(url, params);
|
||||
return res.data || [];
|
||||
} else {
|
||||
const lokiURL = `${LOKI_ENDPOINT}/${url}`;
|
||||
const res = await lastValueFrom(this._request(lokiURL, params, { hideFromInspector: true }));
|
||||
return res.data.data || [];
|
||||
}
|
||||
}
|
||||
|
||||
async metricFindQuery(query: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user