From 2bbf4b21c3ce7b92bfd7044ac49388d76441c73a Mon Sep 17 00:00:00 2001 From: Thibault Deutsch Date: Wed, 27 Jan 2021 22:09:16 +0100 Subject: [PATCH] logcli: support --include-label when not using --tail (#3229) --- pkg/logcli/query/query.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/logcli/query/query.go b/pkg/logcli/query/query.go index e38348182f236..43added3f72ab 100644 --- a/pkg/logcli/query/query.go +++ b/pkg/logcli/query/query.go @@ -274,6 +274,10 @@ func (q *Query) printStream(streams loghttp.Streams, out output.LogOutput, lastE log.Println("Ignoring labels key:", color.RedString(strings.Join(q.IgnoreLabelsKey, ","))) } + if len(q.ShowLabelsKey) > 0 && !q.Quiet { + log.Println("Print only labels key:", color.RedString(strings.Join(q.ShowLabelsKey, ","))) + } + // Remove ignored and common labels from the cached labels and // calculate the max labels length maxLabelsLen := q.FixedLabelsLen @@ -281,6 +285,10 @@ func (q *Query) printStream(streams loghttp.Streams, out output.LogOutput, lastE // Remove common labels ls := subtract(s.Labels, common) + if len(q.ShowLabelsKey) > 0 { + ls = matchLabels(true, ls, q.ShowLabelsKey) + } + // Remove ignored labels if len(q.IgnoreLabelsKey) > 0 { ls = matchLabels(false, ls, q.IgnoreLabelsKey)