我正在尝试在Kubernetes上使用Prometheus监视Spring Boot应用程序。 Promethus是在Helm上安装的,而我正在使用Spring Boot Actuator进行运行状况检查,审计,度量收集和监视。
执行器提供有关应用的详细信息。例如http://**IP:Port**/actuator/health
在输出下方返回
{"status":"UP"}.
我使用下面的配置文件在promethus中添加应用程序端点。
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: scp-service-creator
namespace: sc678
labels:
app: scp-service-creator
release: prometheus-operator
spec:
selector:
matchLabels:
app: scp-service-creator
endpoints:
- port: api
path: "/actuator/prometheus"
scheme: http
interval: 10s
honorLabels: true
所以我的问题是服务甚至被添加到prometheus中,没有分配端点。
那么,这里出什么问题了。非常感谢您的帮助。
谢谢。
最佳答案
从Spring Boot Actuator documentation,更具体地说Endpoints部分。可以看到默认情况下启用了终结点,但禁用了Shutdown
,但仅公开了health
和info
。
可以检查here。
您需要手动公开所需的端点。
要使用的端点Prometheus
对JMX不可用,对Web禁用。
To change which endpoints are exposed, use the following technology-specific
include
andexclude
properties:Property | Default
management.endpoints.jmx.exposure.exclude
|
management.endpoints.jmx.exposure.include
| *
management.endpoints.web.exposure.exclude
|
management.endpoints.web.exposure.include
|info, health
The
include
property lists the IDs of the endpoints that are exposed. Theexclude
property lists the IDs of the endpoints that should not be exposed. Theexclude
property takes precedence over theinclude
property. Bothinclude
andexclude
properties can be configured with a list of endpoint IDs.For example, to stop exposing all endpoints over JMX and only expose the
health
andinfo
endpoints, use the following property:
management.endpoints.jmx.exposure.include=health,info
*
can be used to select all endpoints. For example, to expose everything over HTTP except theenv
andbeans
endpoints, use the following properties:
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
关于kubernetes - 在Kubernetes上使用Prometheus监视Spring Boot Apps,而不设置端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56339565/