Skip to content

PromQL proxy drops Connection host path prefix (breaks VictoriaMetrics cluster) #3046

Description

@milansanjeev

What happened?

proxyToPrometheus builds the upstream URL with new URL(path, upstreamHost) (packages/api/src/routers/api/prometheus.ts). Every proxied path is absolute (/api/v1/query_range, /api/v1/query, /api/v1/query_exemplars, /api/v1/label/${labelName}/values).

JavaScript's URL(absolutePath, base)replaces the base URL's pathname instead of appending to it, so any path segment configured on the Connection host is silently dropped.

This makes PromQL fundamentally incompatible with VictoriaMetrics cluster mode, which requires /select/<accountID>/prometheus on every request. Single-node Prometheus / Thanos / VM single-node are unaffected because they serve at /.

Steps to reproduce

  1. Set a Connection's Host to a VictoriaMetrics cluster vmselect endpoint with its required tenant path, e.g. http://<vmselect-host>:8481/select/0/prometheus
  2. Enable Prometheus compatible on that connection
  3. Create a PromQL source against it
  4. Run any query (or open the metrics browser, which hits /label/__name__/values)

Expected

http://<vmselect-host>:8481/select/0/prometheus/api/v1/query_range?...

Actual

http://<vmselect-host>:8481/api/v1/query_range?...

VictoriaMetrics rejects it with:

unsupported URL format for path "/api/v1/query_range". Make sure you're using cluster URL format...

Same failure on /api/v1/label/__name__/values.

How are you running HyperDX?

Self-hosted HyperDX with an external Prometheus-compatible Connection pointed at VictoriaMetrics cluster vmselect.

Where does it show up?

  • Search / charts PromQL queries (/query_range, /query)
  • Metrics browser label values
  • Exemplars proxy (/query_exemplars)

Suggested fix

Join the base URL's existing pathname with path instead of letting URL()'s absolute-path resolution discard it:

consturl=newURL(upstreamHost);url.pathname=url.pathname.replace(/\/$/,'')+path;

Keep query/search/auth from the Connection host; only the pathname join changes.

Additional context

Introduced with the external Prometheus datastore proxy (#2518). proxyToPrometheus is the shared helper for all four routes above, so one pathname-join fix covers all of them.

Activity

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