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:
Sven Grossmann
2025-01-09 16:29:59 +01:00
committed by GitHub
parent e0121055fb
commit 5a86f032f1
2 changed files with 3 additions and 2 deletions

View File

@@ -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']);
});
});
});

View File

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