diff --git a/public/app/plugins/datasource/loki/LanguageProvider.test.ts b/public/app/plugins/datasource/loki/LanguageProvider.test.ts index c397934b356..c801a15c7a5 100644 --- a/public/app/plugins/datasource/loki/LanguageProvider.test.ts +++ b/public/app/plugins/datasource/loki/LanguageProvider.test.ts @@ -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']); + }); }); }); diff --git a/public/app/plugins/datasource/loki/LanguageProvider.ts b/public/app/plugins/datasource/loki/LanguageProvider.ts index e56acf6f3d7..5d6e5684f2b 100644 --- a/public/app/plugins/datasource/loki/LanguageProvider.ts +++ b/public/app/plugins/datasource/loki/LanguageProvider.ts @@ -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; }