promql: info function: fix series without identifying labels not being returned (#17898)
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

* promql: info function: fix series without identifying labels not being returned

---------

Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
This commit is contained in:
zenador 2026-01-20 23:53:27 +08:00 committed by GitHub
parent c021f316ba
commit e3b6eee437
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 0 deletions

View file

@ -143,6 +143,23 @@ func (ev *evaluator) fetchInfoSeries(ctx context.Context, mat Matrix, ignoreSeri
}
}
if len(idLblValues) == 0 {
// Even when returning early, we need to remove __name__ from dataLabelMatchers
// since it's not a data label selector (it's used to select which info metrics
// to consider). Without this, combineWithInfoVector would incorrectly exclude
// series when only __name__ is specified in the selector.
for name, ms := range dataLabelMatchers {
for i, m := range ms {
if m.Name == labels.MetricName {
ms = slices.Delete(ms, i, i+1)
break
}
}
if len(ms) > 0 {
dataLabelMatchers[name] = ms
} else {
delete(dataLabelMatchers, name)
}
}
return nil, nil, nil
}

View file

@ -166,3 +166,35 @@ eval range from 0 to 2m step 1m info({job="work"}, {__name__="info_metric"})
data_metric{instance="a", job="work", state="running", label="new"} _ _ 30
info_metric{instance="b", job="work", state="stopped"} 1 1 1
info_metric{instance="a", job="work", state="running"} 1 1 1
clear
load 1m
data_metric{} 1 2 3
eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
data_metric{} 1 2 3
clear
load 1m
data_metric{} 1 2 3
data_metric{instance="a"} 4 5 6
eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
data_metric{} 1 2 3
data_metric{instance="a"} 4 5 6
clear
load 1m
data_metric{} 1 2 3
data_metric{instance="a"} 4 5 6
data_metric{job="1"} 7 8 9
data_metric{instance="a", job="1"} 10 20 30
eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
data_metric{} 1 2 3
data_metric{instance="a"} 4 5 6
data_metric{job="1"} 7 8 9
data_metric{instance="a", job="1"} 10 20 30