Skip to content

Commit

Permalink
Fix bug with new promtail stream lag metric where labels might not be (
Browse files Browse the repository at this point in the history
…#5675)

applied if they don't exist on the source stream

Signed-off-by: Callum Styan <callumstyan@gmail.com>
  • Loading branch information
cstyan authored Mar 21, 2022
1 parent 0c5900e commit 2c2578e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions clients/pkg/promtail/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,16 @@ func (c *client) sendBatch(tenantID string, batch *batch) {
return
}
lblSet := make(prometheus.Labels)
for i := range lbls {
for _, lbl := range c.streamLagLabels {
for _, lbl := range c.streamLagLabels {
// label from streamLagLabels may not be found but we still need an empty value
// so that the prometheus client library doesn't panic on inconsistent label cardinality
value := ""
for i := range lbls {
if lbls[i].Name == lbl {
lblSet[lbl] = lbls[i].Value
value = lbls[i].Value
}
}
lblSet[lbl] = value
}
if lblSet != nil {
// always set host
Expand Down

0 comments on commit 2c2578e

Please sign in to comment.