fix promtool analyze block shows metric name with 0 cardinality (#15438)

Signed-off-by: Ben Ye <benye@amazon.com>
This commit is contained in:
Ben Ye 2024-11-24 08:30:20 -08:00 committed by GitHub
parent e664c16b31
commit 40c3ba9fd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -589,7 +589,10 @@ func analyzeBlock(ctx context.Context, path, blockID string, limit int, runExten
if err != nil { if err != nil {
return err return err
} }
postings = index.Intersect(postings, index.NewListPostings(refs)) // Only intersect postings if matchers are specified.
if len(matchers) > 0 {
postings = index.Intersect(postings, index.NewListPostings(refs))
}
count := 0 count := 0
for postings.Next() { for postings.Next() {
count++ count++