Loki: Hide internal labels (#97323)

This commit is contained in:
Sven Grossmann 2024-12-03 12:46:42 +01:00 committed by GitHub
parent cdf7ac6fd8
commit 34134d0e90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -441,6 +441,14 @@ describe('Language completion provider', () => {
start: 1560153109000,
});
});
it('should filter internal labels', async () => {
const datasourceWithLabels = setup({ foo: [], bar: [], __name__: [], __stream_shard__: [] });
const instance = new LanguageProvider(datasourceWithLabels);
const labels = await instance.fetchLabels();
expect(labels).toEqual(['bar', 'foo']);
});
});
});

View File

@ -176,7 +176,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
const labels = res
.slice()
.sort()
.filter((label) => label !== '__name__');
.filter((label: string) => label.startsWith('__') === false);
this.labelKeys = labels;
return this.labelKeys;
}