Skip to content

Commit

Permalink
logcli: support --include-label when not using --tail (#3229)
Browse files Browse the repository at this point in the history
  • Loading branch information
dethi authored Jan 27, 2021
1 parent 8716e24 commit 2bbf4b2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/logcli/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,21 @@ 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
for i, s := range streams {
// 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)
Expand Down

0 comments on commit 2bbf4b2

Please sign in to comment.