Skip to content

Respect the path of --remote-url instead of always appending api/v1/write#196

Open
jmichalek132 wants to merge 2 commits into
prometheus-community:mainfrom
jmichalek132:fix-remote-url-path
Open

Respect the path of --remote-url instead of always appending api/v1/write#196
jmichalek132 wants to merge 2 commits into
prometheus-community:mainfrom
jmichalek132:fix-remote-url-path

Conversation

@jmichalek132

Copy link
Copy Markdown
Contributor

Fixes #173

Since the migration to client_golang's exp/api/remote client, remote.NewAPI joins its default path (api/v1/write) onto whatever path --remote-url carries. Non-default endpoints such as Thanos Receive's /api/v1/receive become /api/v1/receive/api/v1/write and 404; the only workaround was pinning image v0.6.0.

With this change, a --remote-url path is respected, subject to the client's path cleaning (trailing and duplicate slashes are dropped; query strings and percent-encoded segments survive). Host-only URLs keep the api/v1/write default. A bare / also gets the default: posting samples to / is almost never intended, so this deliberately deviates from the pre-0.7.0 behavior for that one case. Flag help updated to match.

Compatibility note: URLs that relied on the current prefix behavior (http://host/prometheus resolving to /prometheus/api/v1/write) now post to /prometheus directly. This restores the pre-exp-client (<= v0.6.0) behavior where the URL path was respected. If you would rather keep prefix semantics, an alternative is a dedicated path-override flag; happy to rework in that direction. The CHANGELOG entry calls this out as well.

Tested with a table test covering host-only, root-path, custom-path, trailing-slash, prefix-path, query-string, escaped-segment, and double-slash URLs, for both v1 and v2 message types, against an httptest receiver.

…rite

The migration to client_golang's exp/api/remote client made remote.NewAPI
join its default path (api/v1/write) onto whatever path --remote-url
carries, so non-default endpoints such as Thanos Receive's /api/v1/receive
became unreachable. Pass an empty API path when the URL has one, keeping
the previous default for host-only URLs.

Fixes prometheus-community#173

Signed-off-by: Juraj Michalek <juraj.michalek@grafana.com>
Signed-off-by: Juraj Michalek <juraj.michalek@grafana.com>
@jmichalek132
jmichalek132 force-pushed the fix-remote-url-path branch from c988858 to 9cbc239 Compare July 15, 2026 15:17
@jmichalek132
jmichalek132 marked this pull request as ready for review July 15, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

avalanche overrides remote url path

1 participant