Fix bug with new promtail stream lag metric where labels might not be (#5675)

applied if they don't exist on the source stream

Signed-off-by: Callum Styan <callumstyan@gmail.com>
pull/5687/head
Callum Styan 3 years ago committed by GitHub
parent 0c5900e407
commit 2c2578e84c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      clients/pkg/promtail/client/client.go

@ -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 {
// 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

Loading…
Cancel
Save