Werk #20185 · Jul 21, 26
Prometheus special agent: fix wrong URL for reverse-proxied connections
Previously, when the Prometheus "URL server address" (connection) included a
path suffix, for example when Prometheus runs behind a reverse proxy under a
subpath like example.com/prometheus, the special agent queried the wrong
URL when looking up the Prometheus build info (used for the Prometheus
Build service). The subpath, together with the API's /api/v1/ prefix, was
silently dropped from the request URL.
Depending on how the reverse proxy responded to that wrong URL, this could make the special agent fail with an error such as:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This has been fixed. The special agent now queries these endpoints under the full configured URL, including any reverse-proxy subpath.
Technical background
The bug was caused by a leading slash in the endpoint paths passed to the
special agent's internal HTTP client. Combined with Python's
urllib.parse.urljoin(), a leading slash resolves the endpoint relative to
the domain root instead of the configured base URL, discarding the /api/v1/
prefix and any reverse-proxy subpath.
Details
- Class:
- Bug Fixes
- Level:
- Trivial
- Component:
- Checks
- Versions:
- 3.0.0b1Not yet releasedAll Editions
- 2.5.0p11All Editions
- 2.4.0p36All Editions