diff --git a/public/app/plugins/datasource/loki/LanguageProvider.test.ts b/public/app/plugins/datasource/loki/LanguageProvider.test.ts index 30ae4ab9a06..4a35e193cb6 100644 --- a/public/app/plugins/datasource/loki/LanguageProvider.test.ts +++ b/public/app/plugins/datasource/loki/LanguageProvider.test.ts @@ -490,7 +490,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider(datasourceWithLabels); const labels = await instance.fetchLabels(); - expect(labels).toEqual(['bar', 'foo']); + expect(labels).toEqual(['__name__', 'bar', 'foo']); }); }); }); diff --git a/public/app/plugins/datasource/loki/LanguageProvider.ts b/public/app/plugins/datasource/loki/LanguageProvider.ts index 9dadc1c2bab..4d6af9a10b7 100644 --- a/public/app/plugins/datasource/loki/LanguageProvider.ts +++ b/public/app/plugins/datasource/loki/LanguageProvider.ts @@ -17,6 +17,7 @@ import { ParserAndLabelKeysResult, LokiQuery, LokiQueryType, LabelType } from '. const NS_IN_MS = 1000000; const EMPTY_SELECTOR = '{}'; +const HIDDEN_LABELS = ['__aggregrated_metric__', '__tenant_id__', '__stream_shard__']; export default class LokiLanguageProvider extends LanguageProvider { labelKeys: string[]; @@ -182,7 +183,7 @@ export default class LokiLanguageProvider extends LanguageProvider { const labels = Array.from(new Set(res)) .slice() .sort() - .filter((label: string) => label.startsWith('__') === false); + .filter((label: string) => HIDDEN_LABELS.includes(label) === false); this.labelKeys = labels; return this.labelKeys; }