Loki: Hide internal labels (#97323)

pull/97349/head
Sven Grossmann 8 months ago committed by GitHub
parent cdf7ac6fd8
commit 34134d0e90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      public/app/plugins/datasource/loki/LanguageProvider.test.ts
  2. 2
      public/app/plugins/datasource/loki/LanguageProvider.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']);
});
});
});

@ -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;
}

Loading…
Cancel
Save