jaegertracing / jaeger

CNCF Jaeger, a Distributed Tracing Platform
https://www.jaegertracing.io/
Apache License 2.0
19.85k stars 2.37k forks source link

[Feature]: Support external URL prefix #5157

Open Sidhartha-Biswal opened 5 months ago

Sidhartha-Biswal commented 5 months ago

Requirement

There are 2 prefixes, local (current implementation) and external (to be used from the UI). Jaeger supports the local prefix and does not support external prefix currently. Please check the below discussion for more details. https://github.com/orgs/jaegertracing/discussions/5042#discussioncomment-8236479

Problem

The traffic flow is gateway>virtual service>gateway>jaeger query.

We are setting the query_base_path as "/jaeger/viewer" and then doing the rewrite using the virtual service configuration mentioned below.

match:
    uri:
    prefix: /jaeger/viewer
    rewrite:
    uri: /hub/jaeger-query/v1/jaeger/viewer
    retries:
    attempts: 3
    perTryTimeout: 15s
    retryOn: connect-failure,refused-stream,reset,unavailable,cancelled,resource-exhausted
    route:
    destination:
    host: api-gateway
    port:
    number: 8080
    timeout: 15s

We are getting issue in the Jaeger UI.The index.html is getting loaded but the static files like index.js, index.css are showing loading error(404 not found) in the console tab of the browser.

Proposal

No response

Open questions

No response

yurishkuro commented 5 months ago

We have an example examples/reverse-proxy/docker-compose.yml that uses Jaeger UI with a base-path. However, it only works because both the base-path arg to Jaeger and the configuration in httpd use the same prefix /jaeger/prefix. If they are made different the example does not work, which is similar to this ticket.

Implementation-wise, Jaeger-UI uses base-path string to remove a prefix from the URLs (as seen by the query service) when loading the corresponding embedded static assets and when mapping the API routes. https://github.com/jaegertracing/jaeger/blob/e08f576fd64a992ef0396112bc8401472cc9dd92/cmd/query/app/static_handler.go#L90

It also injects that path into the main index.html as base, and the UI uses it when constructing URLs (both assets and API paths). https://github.com/jaegertracing/jaeger/blob/e08f576fd64a992ef0396112bc8401472cc9dd92/cmd/query/app/static_handler.go#L142-L147

Basically we combine the internal view of the URLs as seen by the query server and the external URLs used by the browser, and by using a single --query.base-path arg for them we artificially force them to be the same. If we introduce another arg, e.g. --query.ui-base-path, just for injecting into the UI, it would allow the external prefix to be different. The above-mentioned docker-compose can be used to validate that it's working.

akagami-harsh commented 5 months ago

I'll work on it.

joeyyy09 commented 2 months ago

@yurishkuro Is this issue resolved or can i take it up?

yurishkuro commented 2 months ago

It's not resolved afaik, you can see discussion in the linked PR #5219