Skip to content

QueryRange: Catalogs range validation as an internal error #3163

@gotjosh

Description

@gotjosh

Time ranges for range queries are validated against a per-tenant limit.

startTime := model.Time(sp.Start)
endTime := model.Time(sp.End)
if maxQueryLength := q.limits.MaxQueryLength(userID); maxQueryLength > 0 && endTime.Sub(startTime) > maxQueryLength {
return storage.ErrSeriesSet(fmt.Errorf(validation.ErrQueryTooLong, endTime.Sub(startTime), maxQueryLength))
}

Within Prometheus API, the query_range endpoint does all of its validation upfront - meaning that incorrect input errors (400s) are validated before the query is ran.

https://github.com/prometheus/prometheus/blob/a282d2509971174301408c5a5f96946c478dfb0f/web/api/v1/api.go#L387-L452

As it is, Cortex will return a 500 for the validation of this limit which seems incorrect. Any thoughts?

I'm not sure upstream will accept changes to encapsulate custom validation as part of the API, the other options is to copy the validation code of the code of this particular endpoint which seems unideal.

An example of the error:

{
  "status": "error",
  "errorType": "internal",
  "error": "expanding series: the query time range exceeds the limit (query length: 4414h5m0s, limit: 768h0m0s)"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions