mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-03 20:39:32 -05:00
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
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:
parent
c021f316ba
commit
e3b6eee437
2 changed files with 49 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
32
promql/promqltest/testdata/info.test
vendored
32
promql/promqltest/testdata/info.test
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue