mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Only hide a set of labels instead of every label starting with __ (#98730)
Loki: Only hide a set of labels
This commit is contained in:
@@ -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']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user