diff --git a/public/app/plugins/datasource/loki/datasource.test.ts b/public/app/plugins/datasource/loki/datasource.test.ts index 84d47617c1f..64fc678a9fd 100644 --- a/public/app/plugins/datasource/loki/datasource.test.ts +++ b/public/app/plugins/datasource/loki/datasource.test.ts @@ -469,7 +469,9 @@ describe('LokiDatasource', () => { }, { stream: { + label: '', // empty value gets filtered label2: 'value2', + label3: ' ', // whitespace value gets trimmed then filtered }, values: [['1549024057498000000', 'hello 2']], }, diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 78e15d21718..89d21ab9e07 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -511,7 +511,13 @@ export class LokiDatasource extends DataSourceApi { const tags: string[] = []; for (const field of frame.fields) { if (field.labels) { - tags.push.apply(tags, [...new Set(Object.values(field.labels).map((label: string) => label.trim()))]); + tags.push.apply(tags, [ + ...new Set( + Object.values(field.labels) + .map((label: string) => label.trim()) + .filter((label: string) => label !== '') + ), + ]); } } const view = new DataFrameView<{ ts: string; line: string }>(frame);