【问题标题】:Keycloak http-management returns Connection refusedKeycloak http-management 返回连接被拒绝
【发布时间】:2022-01-15 05:30:00
【问题描述】:

我正在运行 Keycloak 14,并希望从中获取指标数据。

所以我将 Prometheus 配置为抓取 http://KEYCLOAK_HOST:9990/metrics。不幸的是,这给了我一个“连接被拒绝”。

当我尝试从另一台主机手动连接时,我得到了相同的结果:

user@host:/$ curl -vvv 10.244.3.154:9990/metrics
* Expire in 0 ms for 6 (transfer 0x5566ecabbfb0)
*   Trying 10.244.3.154...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x5566ecabbfb0)
* connect to 10.244.3.154 port 9990 failed: Connection refused
* Failed to connect to 10.244.3.154 port 9990: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 10.244.3.154 port 9990: Connection refused
user@host:/$

事实上,我在管理端口上的所有路径上都收到此错误。即使在那些上,也不存在:

user@host:/$ curl -vvv 10.244.3.154:9990/some_endpoint
* Expire in 0 ms for 6 (transfer 0x55eea4059fb0)
*   Trying 10.244.3.154...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55eea4059fb0)
* connect to 10.244.3.154 port 9990 failed: Connection refused
* Failed to connect to 10.244.3.154 port 9990: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 10.244.3.154 port 9990: Connection refused
user@host:/$

在 Keycloak 主机中它可以正常工作:

bash-4.4$ curl -vvv localhost:9990/metrics
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9990 (#0)
> GET /metrics HTTP/1.1
> Host: localhost:9990
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
...
bash-4.4$

它只适用于localhost

bash-4.4$ hostname -I
10.244.3.154
bash-4.4$ curl -vvv 10.244.3.154:9990/metrics
*   Trying 10.244.3.154...
* TCP_NODELAY set
* connect to 10.244.3.154 port 9990 failed: Connection refused
* Failed to connect to 10.244.3.154 port 9990: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 10.244.3.154 port 9990: Connection refused
bash-4.4$

所以我假设 Keycloak 没有“向外界”提供管理端点。但是如何启用呢?

我正在使用codecentric Helm 图表进行部署 (https://github.com/codecentric/helm-charts/tree/master/charts/keycloak)。我现在正在运行 Keycloak 14.0.0,但在 15.x 上遇到了同样的问题(由于错误,现在无法更新)。

提前致谢!

【问题讨论】:

标签: docker kubernetes keycloak prometheus metrics


【解决方案1】:

在 Helm 图表的文档中发现,我必须通过将环境变量 KEYCLOAK_STATISTICS 设置为 all 来启用它。

https://github.com/codecentric/helm-charts/tree/master/charts/keycloak#prometheus-metrics-support

【讨论】:

    猜你喜欢
    • 2021-06-12
    • 2020-05-03
    • 2018-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多