alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

kubectl proxy doesn't serve the webUI

Open Xartos opened this issue 4 weeks ago • 3 comments

What did you do?

When trying to use the kubectl proxy command after upgrading from v0.31.1 to v0.32.0 I tried to reach the alertmanager UI using the URLs:

  • http://127.0.0.1:8001/api/v1/namespaces/monitoring/services/alertmanager-operated:9093/proxy
  • http://127.0.0.1:8001/api/v1/namespaces/monitoring/services/alertmanager-operated:9093/proxy/#/alerts

None of these works after the upgrade, which they did before the upgrade. The API is still working as expected from what I can see.

Tested on kubernetes v1.35.6 and kubectl v1.35.10

Using kubectl port-forward works as expected, only kubectl proxy seems to be broken

What did you expect to see?

Be redirected to /#/alerts and see the web UI

What did you see instead? Under which circumstances?

The browser shows

stream error: stream ID 1; INTERNAL_ERROR; received from peer

And the output from kubectl proxy is

E1103 15:32:34.220447 1186201 proxy_server.go:147] Error while proxying request: stream error: stream ID 1; INTERNAL_ERROR; received from peer

System information

No response

Alertmanager version

Broken versions:
version=0.32.0, branch=HEAD, revision=685a2a1c6bb01b2c17bc1bfae995cb3416c1115e
version=0.34.2, branch=HEAD, revision=e8349048265ccc0871c3d0d668b05eacc68baf50

Working version:
version=0.31.1, branch=HEAD, revision=7a639ba087d6e877038cabfdaa645230f79001b8

Alertmanager configuration file


Prometheus version


Prometheus configuration file


Logs


CPU profiles

No response

Memory profiles

No response

Number of alerts

No response

Number of silences

No response

prometheus-operator checklist

  • [x] I have confirmed this issue is not caused by a missing feature in prometheus-operator.
  • [ ] I have reproduced this issue when running Alertmanager directly (without prometheus-operator).

Xartos avatar Nov 03 '26 14:11 Xartos

It looks like this is a result of https://github.com/prometheus/alertmanager/pull/5133 which introduced precompressed HTML serving and preference for Brotli whenever the client advertises. And kubectl proxy does not support brotli

TheMeier avatar Nov 03 '26 17:11 TheMeier

Confirmed, thanks @TheMeier for the pointer. The API server service proxy that kubectl proxy goes through rewrites links in text/html responses and only knows gzip and deflate. On a br body it logs "Proxy encountered unknown encoding for text/html" and returns the response with the body already closed, which ends up as the stream error. JS/CSS are fine since only HTML is rewritten. I reproduced it with apimachinery's proxy transport in front of the UI handler.

Fix in #5724: HTML is no longer served with Brotli, browsers get the gzip variant.

lbarrosby avatar Nov 04 '26 05:11 lbarrosby

Generally, it would be better to fix the software causing the issue, not Alertmanager. It would be very bad for our project, if we stopped improving things, because other parts have the ecosystem have bugs.

Of course, Kubernetes isn't just any piece of software, so I am considering making an exception, but it sounds to me like that are many ways to work around this bug? How about rewriting the headers using nginx? Why does kubectl proxy specifically need to work with Alertmanager?

I definitely don't won't to add a workaround without making the Kubernetes Team aware first.

SoloJacobs avatar Nov 05 '26 12:11 SoloJacobs