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

标签 kubernetes grafana prometheus kubernetes-helm spring-boot-actuator

我正在尝试在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/

相关文章:

普罗米修斯-格拉法纳 : How to use wildcard in query

kubernetes - 如何获取在 prometheus 中运行的 Pod 数量

kubernetes - kubectl exec失败,出现错误 "Unable to use a TTY - input is not a terminal or the right kind of file"

security - kubectl 如何比 SSH 守护程序/访问容器更安全?

kubernetes - minReadySeconds如何影响就绪探针?

elasticsearch - 无法在 Ubuntu 上的 kubernetes cluser 中访问 Kibana 仪表板服务

kubernetes - 在尝试部署 Prometheus 时出现错误 : found in Chart. yaml,但在图表/目录中丢失:kube-state-metrics

sql - Postgresql - 分组依据

grafana - 如何访问变量,通过grafana中的URL传递?

kubernetes - 在 Kubernetes 上将 statsd-exporter 设置为守护进程,并从 pod 向其发送指标