【发布时间】: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 上遇到了同样的问题(由于错误,现在无法更新)。
提前致谢!
【问题讨论】:
-
您可以发布您用于 helm install 的值吗?
-
我并没有真正在那里配置任何东西。我启用了
ingress和postgres,配置了serviceMonitor和extraServiceMonitor并添加了prometheusRule(使用来自keycloak-operator存储库的规则)。我能想到的唯一有趣的事情是我添加了一个额外的初始化容器,它安装了metrics-spi-provider。您可以在此处查看设置:stackoverflow.com/questions/69751203/…(当时我使用的是另一个图表,但脚本没有更改)。 -
好的 nvm。在 Charts repo 中发现了一个指向文档的问题。 * github.com/codecentric/helm-charts/issues/436 * github.com/codecentric/helm-charts/tree/master/charts/…
标签: docker kubernetes keycloak prometheus metrics