You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ curl 'http://localhost:8080/actuator/prometheus' -i -X GET
返回结果如下所示:
HTTP/1.1 200 OKContent-Type: text/plain;version=0.0.4;charset=utf-8Content-Length: 2375# HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool# TYPE jvm_buffer_memory_used_bytes gaugejvm_buffer_memory_used_bytes{id="direct",} 489719.0jvm_buffer_memory_used_bytes{id="mapped",} 0.0# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use# TYPE jvm_memory_committed_bytes gaugejvm_memory_committed_bytes{area="heap",id="PS Survivor Space",} 5.1380224E7jvm_memory_committed_bytes{area="heap",id="PS Old Gen",} 4.86539264E8jvm_memory_committed_bytes{area="heap",id="PS Eden Space",} 2.11812352E8jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 1.62439168E8jvm_memory_committed_bytes{area="nonheap",id="Code Cache",} 5.4329344E7jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 2.4551424E7# HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers in this pool# TYPE jvm_buffer_total_capacity_bytes gaugejvm_buffer_total_capacity_bytes{id="direct",} 489718.0jvm_buffer_total_capacity_bytes{id="mapped",} 0.0# HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management# TYPE jvm_memory_max_bytes gaugejvm_memory_max_bytes{area="heap",id="PS Survivor Space",} 5.1380224E7jvm_memory_max_bytes{area="heap",id="PS Old Gen",} 7.16177408E8jvm_memory_max_bytes{area="heap",id="PS Eden Space",} 2.31735296E8jvm_memory_max_bytes{area="nonheap",id="Metaspace",} -1.0jvm_memory_max_bytes{area="nonheap",id="Code Cache",} 2.5165824E8jvm_memory_max_bytes{area="nonheap",id="Compressed Class Space",} 1.073741824E9# HELP jvm_buffer_count_buffers An estimate of the number of buffers in the pool# TYPE jvm_buffer_count_buffers gaugejvm_buffer_count_buffers{id="direct",} 17.0jvm_buffer_count_buffers{id="mapped",} 0.0# HELP jvm_memory_used_bytes The amount of used memory# TYPE jvm_memory_used_bytes gaugejvm_memory_used_bytes{area="heap",id="PS Survivor Space",} 5.1139432E7jvm_memory_used_bytes{area="heap",id="PS Old Gen",} 9.7572216E7jvm_memory_used_bytes{area="heap",id="PS Eden Space",} 1.47234248E8jvm_memory_used_bytes{area="nonheap",id="Metaspace",} 1.46403048E8jvm_memory_used_bytes{area="nonheap",id="Code Cache",} 5.3970112E7jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space",} 2.1374208E7
配置 Service
因为应用是部署在 k8s 上的,由多个 Pod 组成,所以还需要为 Pod 添加 Service,对外提供 HTTP 服务,这样 Prometheus 才可以抓取监控指标。
Activity
ldcsaa commentedon May 15, 2023
那 service 的 pod 实例如何监控呢?
tsejx commentedon May 15, 2023
nodejh commentedon May 16, 2023
@ldcsaa k8s 内置了 cAdvisor 用于采集集群中 Pod 相关的性能指标,这些指标可以直接使用,另外也可以使用 node-exporter 采集机器的指标。然后在 Prometheus 中去抓取
/metric接口的数据就可以了。本文主要侧重于 Spring Boot 应用相关的监控,比如应用的负载、JVM 指标等,这些指标需要自己采集,本文则描述了如何采集这些指标。
不管什么指标,采集后用 Prometheus 统一抓取数据,再用 Grafana 展示数据就好了。