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', () => {
|
describe('importing queries', () => {
|
||||||
it('keeps all labels when no labels are loaded', async () => {
|
it('keeps all labels when no labels are loaded', async () => {
|
||||||
const ds = createLokiDSForTests();
|
const ds = createLokiDSForTests();
|
||||||
ds.getResource = () => Promise.resolve({ data: [] });
|
fetchMock.mockImplementation(() => of(createFetchResponse({ data: [] })));
|
||||||
const queries = await ds.importFromAbstractQueries([
|
const queries = await ds.importFromAbstractQueries([
|
||||||
{
|
{
|
||||||
refId: 'A',
|
refId: 'A',
|
||||||
@ -1017,9 +1017,7 @@ describe('LokiDatasource', () => {
|
|||||||
|
|
||||||
it('filters out non existing labels', async () => {
|
it('filters out non existing labels', async () => {
|
||||||
const ds = createLokiDSForTests();
|
const ds = createLokiDSForTests();
|
||||||
ds.getResource = () => {
|
fetchMock.mockImplementation(() => of(createFetchResponse({ data: ['foo'] })));
|
||||||
return Promise.resolve({ data: ['foo'] });
|
|
||||||
};
|
|
||||||
const queries = await ds.importFromAbstractQueries([
|
const queries = await ds.importFromAbstractQueries([
|
||||||
{
|
{
|
||||||
refId: 'A',
|
refId: 'A',
|
||||||
|
@ -467,8 +467,15 @@ export class LokiDatasource
|
|||||||
if (url.startsWith('/')) {
|
if (url.startsWith('/')) {
|
||||||
throw new Error(`invalid metadata request url: ${url}`);
|
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) {
|
async metricFindQuery(query: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user