gpt4 book ai didi

kubernetes - 在Kubernetes上使用Prometheus监视Spring Boot Apps,而不设置端点

转载 作者:行者123 更新时间:2023-12-02 12:35:49 27 4
gpt4 key购买 nike

我正在尝试在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中,没有分配端点。
那么,这里出什么问题了。非常感谢您的帮助。

targets in promethus

service-discovery in promethus

谢谢。

最佳答案

Spring Boot Actuator documentation,更具体地说Endpoints部分。可以看到默认情况下启用了终结点,但禁用了Shutdown,但仅公开了healthinfo

可以检查here

您需要手动公开所需的端点。

要使用的端点Prometheus对JMX不可用,对Web禁用。

To change which endpoints are exposed, use the following technology-specific include and exclude 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. The exclude property lists the IDs of the endpoints that should not be exposed. The excludeproperty takes precedence over the include property. Both include and exclude properties can be configured with a list of endpoint IDs.

For example, to stop exposing all endpoints over JMX and only expose the health and info 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 the env and beans 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com