Skip to content

Commit ba8f5eb

Browse files
authored
docs: document scrape query limits in request API (#2391)
## Summary - document the default implementation values `maxQueryStringLength = 64 * 1024` and `maxQueryParameterCount = 1024` in `PrometheusHttpRequest` JavaDoc - clarify that these values are fixed implementation limits, not runtime configuration - clarify that invalid or excessive query parameters produce HTTP 400 Follow-up to [#2334](#2334) and [discussion_r3752169308](#2334 (comment)). ## Validation - `mise run lint:fix` *(blocked by the pre-existing 403 response for the README CNCF Slack link; the push hook passed using a temporary local-only README substitution, restored before completion)* - `mise run build` - `./mvnw -pl prometheus-metrics-exporter-common test -Dcoverage.skip=true` --------- Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent e5fa067 commit ba8f5eb

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎docs/content/exporters/filter.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ params:
2323
2424
For safety, exporters limit the query string to 65,536 characters and accept at most 1,024
2525
query parameters. The parameter limit counts every `&`-separated pair, including repeated
26-
parameters and empty pairs.
26+
parameters and empty pairs. These are fixed implementation limits and cannot be changed through
27+
runtime configuration.
2728

2829
If a request exceeds either limit or contains invalid percent-encoding, the `/metrics` endpoint
2930
returns HTTP `400 Bad Request` with the plain-text response `Invalid query parameters`.

‎prometheus-metrics-exporter-common/src/main/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequest.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ default String getParameter(String name) {
4141
}
4242
}
4343

44-
/** See {@code jakarta.servlet.ServletRequest.getParameterValues(String)} */
44+
/**
45+
* See {@code jakarta.servlet.ServletRequest.getParameterValues(String)}.
46+
*
47+
* <p>For safety, the default implementation applies two fixed limits: {@code maxQueryStringLength
48+
* = 64 * 1024} (65,536 characters) and {@code maxQueryParameterCount = 1024} ({@code &}-separated
49+
* parameter pairs). These implementation values are not exposed as runtime configuration.
50+
* Requests that exceed either limit or contain invalid percent-encoding are rejected by the
51+
* scrape handler with HTTP {@code 400 Bad Request}.
52+
*/
4553
@Override
4654
@Nullable
4755
// decode with Charset is only available in Java 10+, but we want to support Java 8

0 commit comments

Comments
 (0)