Apply suggestions from code review

Co-authored-by: Björn Rabenstein <github@rabenste.in>
Signed-off-by: Vandit Singh <107131545+Vandit1604@users.noreply.github.com>
This commit is contained in:
Vandit Singh 2024-12-18 21:58:27 +05:30 committed by GitHub
parent e8afb9c990
commit f736a6f7af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -86,7 +86,7 @@ URL query parameters:
- `time=<rfc3339 | unix_timestamp>`: Evaluation timestamp. Optional.
- `timeout=<duration>`: Evaluation timeout. Optional. Defaults to and
is capped by the value of the `-query.timeout` flag.
- `limit=<number>`: Maximum number of returned series. doesnt affect scalars or strings but truncates series for matrices and vectors. Optional.
- `limit=<number>`: Maximum number of returned series. Doesnt affect scalars or strings but truncates the number of series for matrices and vectors. Optional. 0 means disabled.
The current server time is used if the `time` parameter is omitted.
@ -155,7 +155,7 @@ URL query parameters:
- `step=<duration | float>`: Query resolution step width in `duration` format or float number of seconds.
- `timeout=<duration>`: Evaluation timeout. Optional. Defaults to and
is capped by the value of the `-query.timeout` flag.
- `limit=<number>`: Maximum number of returned series. Optional.
- `limit=<number>`: Maximum number of returned series. Optional. 0 means disabled.
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large

View file

@ -480,7 +480,7 @@ func (api *API) query(r *http.Request) (result apiFuncResult) {
return apiFuncResult{nil, returnAPIError(res.Err), res.Warnings, qry.Close}
}
var warnings annotations.Annotations
warnings := res.Warnings
if limit > 0 {
res = truncateResults(res, limit)
warnings = warnings.Add(errors.New("results truncated due to limit"))