Skip to content

PromQL table-function backend has no response size limit: one wide range query can OOM the API #3836

Backlog

Description

@bcanvural

With promqlBackend: table-function, queryRangeViaTableFunction (packages/api/src/controllers/timeseriesEngine.ts) caps the result at max_result_rows (100,000). Each row is a whole series with up to 11,000 samples, so the row cap doesn't bound the size. resp.json() then reads the whole body into memory.

A range query without aggregation over a large cluster, roughly rate(k8s_container_restarts[5m]) > 0 over 1 hour with one series per container, failed with Invalid string length. About a minute later the API process was OOM-killed (exit 137), and every user got 503s until it restarted.

The HTTP backends (prometheus, clickhouse-http) stop reading at PROMETHEUS_MAX_RESPONSE_BYTES (8 MB). On clickhouse-http, the same tile fails cleanly: "... returned more than 8 MB. Narrow the query or time range." The comment on that constant says both backends allow about the same amount of data. That holds for label lookups, but not for range queries.

Expected: the same bound on every backend, so one tile fails with a clear error instead of taking down the API. For example max_result_bytes next to max_result_rows in PROMQL_TABLE_FUNCTION_SETTINGS, or a bounded read of the response body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions