mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Api: Verify that at every matcher in api/v1/series is not empty (#8288)
Fixed #8286 Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
0dd6e0cb76
commit
8dc53c2218
|
@ -587,6 +587,19 @@ func (api *API) series(r *http.Request) (result apiFuncResult) {
|
|||
matcherSets = append(matcherSets, matchers)
|
||||
}
|
||||
|
||||
for _, ms := range matcherSets {
|
||||
var nonEmpty bool
|
||||
for _, lm := range ms {
|
||||
if lm != nil && !lm.Matches("") {
|
||||
nonEmpty = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !nonEmpty {
|
||||
return apiFuncResult{nil, &apiError{errorBadData, errors.New("match[] must contain at least one non-empty matcher")}, nil, nil}
|
||||
}
|
||||
}
|
||||
|
||||
q, err := api.Queryable.Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end))
|
||||
if err != nil {
|
||||
return apiFuncResult{nil, &apiError{errorExec, err}, nil, nil}
|
||||
|
|
|
@ -727,6 +727,13 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, testLabelAPI
|
|||
labels.FromStrings("__name__", "test_metric2", "foo", "boo"),
|
||||
},
|
||||
},
|
||||
{
|
||||
endpoint: api.series,
|
||||
query: url.Values{
|
||||
"match[]": []string{`{foo=""}`},
|
||||
},
|
||||
errType: errorBadData,
|
||||
},
|
||||
{
|
||||
endpoint: api.series,
|
||||
query: url.Values{
|
||||
|
|
Loading…
Reference in a new issue