SpringBoot2.0 Actuator 监控参数说明

基于SpringBoot2.0+ Actuator metrics的监控(基于Oracle JDK9,G1)

引言

SpringBoot2在spring-boot-actuator中引入了micrometer,对1.x的metrics进行了重构,另外支持对接的监控系统也更加丰富(Atlas、Datadog、Ganglia、Graphite、Influx、JMX、NewRelic、Prometheus、SignalFx、StatsD、Wavefront)。本文以Prometheus为例阐述SpringBoot2.0的监控。

eg. Prometheus

Maven坐标

 

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

Prometheus地址

http://ip:port/actuator/prometheus

 
  1. # HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use

  2. # TYPE jvm_memory_committed_bytes gauge

  3. jvm_memory_committed_bytes{area="nonheap",id="Code Cache",} 1.671168E7

  4. jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 4.5481984E7

  5. jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 6160384.0

  6. jvm_memory_committed_bytes{area="heap",id="PS Eden Space",} 1.3631488E8

  7. jvm_memory_committed_bytes{area="heap",id="PS Survivor Space",} 1.4155776E7

  8. jvm_memory_committed_bytes{area="heap",id="PS Old Gen",} 1.08527616E8

  9. # HELP tomcat_cache_access_total

  10. # TYPE tomcat_cache_access_total counter

  11. tomcat_cache_access_total 0.0

  12. # HELP jvm_gc_pause_seconds Time spent in GC pause

  13. # TYPE jvm_gc_pause_seconds summary

  14. jvm_gc_pause_seconds_count{action="end of minor GC",cause="Metadata GC Threshold",} 1.0

  15. jvm_gc_pause_seconds_sum{action="end of minor GC",cause="Metadata GC Threshold",} 0.012

  16. jvm_gc_pause_seconds_count{action="end of major GC",cause="Metadata GC Threshold",} 1.0

  17. jvm_gc_pause_seconds_sum{action="end of major GC",cause="Metadata GC Threshold",} 0.061

  18. jvm_gc_pause_seconds_count{action="end of minor GC",cause="Allocation Failure",} 1.0

  19. jvm_gc_pause_seconds_sum{action="end of minor GC",cause="Allocation Failure",} 0.006

  20. # HELP jvm_gc_pause_seconds_max Time spent in GC pause

  21. # TYPE jvm_gc_pause_seconds_max gauge

  22. jvm_gc_pause_seconds_max{action="end of minor GC",cause="Metadata GC Threshold",} 0.012

  23. jvm_gc_pause_seconds_max{action="end of major GC",cause="Metadata GC Threshold",} 0.061

  24. jvm_gc_pause_seconds_max{action="end of minor GC",cause="Allocation Failure",} 0.006

  25. # HELP jvm_gc_memory_promoted_bytes_total Count of positive increases in the size of the old generation memory pool before GC to after GC

  26. # TYPE jvm_gc_memory_promoted_bytes_total counter

  27. jvm_gc_memory_promoted_bytes_total 1.3522328E7

  28. # HELP jvm_threads_live The current number of live threads including both daemon and non-daemon threads

  29. # TYPE jvm_threads_live gauge

  30. jvm_threads_live 26.0

  31. # HELP jvm_memory_used_bytes The amount of used memory

  32. # TYPE jvm_memory_used_bytes gauge

  33. jvm_memory_used_bytes{area="nonheap",id="Code Cache",} 1.4794432E7

  34. jvm_memory_used_bytes{area="nonheap",id="Metaspace",} 4.2796624E7

  35. jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space",} 5667112.0

  36. jvm_memory_used_bytes{area="heap",id="PS Eden Space",} 1.25566672E8

  37. jvm_memory_used_bytes{area="heap",id="PS Survivor Space",} 6019288.0

  38. jvm_memory_used_bytes{area="heap",id="PS Old Gen",} 2.1067888E7

  39. # HELP tomcat_sessions_rejected_total

  40. # TYPE tomcat_sessions_rejected_total counter

  41. tomcat_sessions_rejected_total 0.0

  42. # HELP jvm_classes_unloaded_total The total number of classes unloaded since the Java virtual machine has started execution

  43. # TYPE jvm_classes_unloaded_total counter

  44. jvm_classes_unloaded_total 0.0

  45. # HELP tomcat_global_request_seconds

  46. # TYPE tomcat_global_request_seconds summary

  47. tomcat_global_request_seconds_count{name="http-nio-8080",} 4.0

  48. tomcat_global_request_seconds_sum{name="http-nio-8080",} 2.004

  49. # HELP tomcat_sessions_expired_total

  50. # TYPE tomcat_sessions_expired_total counter

  51. tomcat_sessions_expired_total 0.0

  52. # HELP tomcat_global_sent_bytes_total

  53. # TYPE tomcat_global_sent_bytes_total counter

  54. tomcat_global_sent_bytes_total{name="http-nio-8080",} 10530.0

  55. # HELP process_cpu_usage The "recent cpu usage" for the Java Virtual Machine process

  56. # TYPE process_cpu_usage gauge

  57. process_cpu_usage 0.0012014831697775476

  58. # HELP tomcat_global_request_max_seconds

  59. # TYPE tomcat_global_request_max_seconds gauge

  60. tomcat_global_request_max_seconds{name="http-nio-8080",} 1.766

  61. # HELP tomcat_sessions_active_max

  62. # TYPE tomcat_sessions_active_max gauge

  63. tomcat_sessions_active_max 0.0

  64. # HELP process_start_time_seconds Start time of the process since unix epoch.

  65. # TYPE process_start_time_seconds gauge

  66. process_start_time_seconds 1.536892441333E9

  67. # HELP tomcat_threads_busy

  68. # TYPE tomcat_threads_busy gauge

  69. tomcat_threads_busy{name="http-nio-8080",} 1.0

  70. # HELP jvm_threads_peak The peak live thread count since the Java virtual machine started or peak was reset

  71. # TYPE jvm_threads_peak gauge

  72. jvm_threads_peak 30.0

  73. # HELP http_server_requests_seconds

  74. # TYPE http_server_requests_seconds summary

  75. http_server_requests_seconds_count{exception="None",method="GET",status="404",uri="/**",} 2.0

  76. http_server_requests_seconds_sum{exception="None",method="GET",status="404",uri="/**",} 0.025440234

  77. http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/actuator/prometheus",} 1.0

  78. http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/actuator/prometheus",} 1.764922568

  79. http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/actuator/metrics",} 1.0

  80. http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/actuator/metrics",} 0.05432998

  81. # HELP http_server_requests_seconds_max

  82. # TYPE http_server_requests_seconds_max gauge

  83. http_server_requests_seconds_max{exception="None",method="GET",status="404",uri="/**",} 0.021481453

  84. http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="/actuator/prometheus",} 1.764922568

  85. http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="/actuator/metrics",} 0.05432998

  86. # HELP process_uptime_seconds The uptime of the Java virtual machine

  87. # TYPE process_uptime_seconds gauge

  88. process_uptime_seconds 159.907

  89. # HELP tomcat_cache_hit_total

  90. # TYPE tomcat_cache_hit_total counter

  91. tomcat_cache_hit_total 0.0

  92. # HELP tomcat_threads_current

  93. # TYPE tomcat_threads_current gauge

  94. tomcat_threads_current{name="http-nio-8080",} 10.0

  95. # HELP logback_events_total Number of error level events that made it to the logs

  96. # TYPE logback_events_total counter

  97. logback_events_total{level="error",} 0.0

  98. logback_events_total{level="warn",} 0.0

  99. logback_events_total{level="info",} 42.0

  100. logback_events_total{level="debug",} 0.0

  101. logback_events_total{level="trace",} 0.0

  102. # HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool

  103. # TYPE jvm_buffer_memory_used_bytes gauge

  104. jvm_buffer_memory_used_bytes{id="direct",} 57344.0

  105. jvm_buffer_memory_used_bytes{id="mapped",} 0.0

  106. # HELP jvm_classes_loaded The number of classes that are currently loaded in the Java virtual machine

  107. # TYPE jvm_classes_loaded gauge

  108. jvm_classes_loaded 8460.0

  109. # HELP tomcat_threads_config_max

  110. # TYPE tomcat_threads_config_max gauge

  111. tomcat_threads_config_max{name="http-nio-8080",} 200.0

  112. # HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers in this pool

  113. # TYPE jvm_buffer_total_capacity_bytes gauge

  114. jvm_buffer_total_capacity_bytes{id="direct",} 57344.0

  115. jvm_buffer_total_capacity_bytes{id="mapped",} 0.0

  116. # HELP tomcat_servlet_error_total

  117. # TYPE tomcat_servlet_error_total counter

  118. tomcat_servlet_error_total{name="default",} 0.0

  119. # HELP system_cpu_usage The "recent cpu usage" for the whole system

  120. # TYPE system_cpu_usage gauge

  121. system_cpu_usage 0.16353571056981642

  122. # HELP jvm_gc_memory_allocated_bytes_total Incremented for an increase in the size of the young generation memory pool after one GC to before the next

  123. # TYPE jvm_gc_memory_allocated_bytes_total counter

  124. jvm_gc_memory_allocated_bytes_total 1.9545368E8

  125. # HELP tomcat_global_received_bytes_total

  126. # TYPE tomcat_global_received_bytes_total counter

  127. tomcat_global_received_bytes_total{name="http-nio-8080",} 0.0

  128. # HELP tomcat_sessions_active_current

  129. # TYPE tomcat_sessions_active_current gauge

  130. tomcat_sessions_active_current 0.0

  131. # HELP system_cpu_count The number of processors available to the Java virtual machine

  132. # TYPE system_cpu_count gauge

  133. system_cpu_count 4.0

  134. # HELP tomcat_sessions_created_total

  135. # TYPE tomcat_sessions_created_total counter

  136. tomcat_sessions_created_total 0.0

  137. # HELP jvm_buffer_count An estimate of the number of buffers in the pool

  138. # TYPE jvm_buffer_count gauge

  139. jvm_buffer_count{id="direct",} 7.0

  140. jvm_buffer_count{id="mapped",} 0.0

  141. # HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management

  142. # TYPE jvm_memory_max_bytes gauge

  143. jvm_memory_max_bytes{area="nonheap",id="Code Cache",} 2.5165824E8

  144. jvm_memory_max_bytes{area="nonheap",id="Metaspace",} -1.0

  145. jvm_memory_max_bytes{area="nonheap",id="Compressed Class Space",} 1.073741824E9

  146. jvm_memory_max_bytes{area="heap",id="PS Eden Space",} 6.80525824E8

  147. jvm_memory_max_bytes{area="heap",id="PS Survivor Space",} 1.4155776E7

  148. jvm_memory_max_bytes{area="heap",id="PS Old Gen",} 1.417674752E9

  149. # HELP jvm_gc_live_data_size_bytes Size of old generation memory pool after a full GC

  150. # TYPE jvm_gc_live_data_size_bytes gauge

  151. jvm_gc_live_data_size_bytes 2.1063808E7

  152. # HELP jvm_threads_daemon The current number of live daemon threads

  153. # TYPE jvm_threads_daemon gauge

  154. jvm_threads_daemon 24.0

  155. # HELP tomcat_servlet_request_seconds

  156. # TYPE tomcat_servlet_request_seconds summary

  157. tomcat_servlet_request_seconds_count{name="default",} 0.0

  158. tomcat_servlet_request_seconds_sum{name="default",} 0.0

  159. # HELP tomcat_servlet_request_max_seconds

  160. # TYPE tomcat_servlet_request_max_seconds gauge

  161. tomcat_servlet_request_max_seconds{name="default",} 0.0

  162. # HELP tomcat_global_error_total

  163. # TYPE tomcat_global_error_total counter

  164. tomcat_global_error_total{name="http-nio-8080",} 2.0

  165. # HELP jvm_gc_max_data_size_bytes Max size of old generation memory pool

  166. # TYPE jvm_gc_max_data_size_bytes gauge

  167. jvm_gc_max_data_size_bytes 1.417674752E9

  168. # HELP tomcat_sessions_alive_max_seconds

  169. # TYPE tomcat_sessions_alive_max_seconds gauge

  170. tomcat_sessions_alive_max_seconds 0.0

SpringBoot2.0 Actuator监控指标分析

序号参数参数说明是否监控监控手段重要度
---JVM---   
1jvm.memory.maxJVM最大内存   
2jvm.memory.committedJVM可用内存展示并监控堆内存和Metaspace重要
3jvm.memory.usedJVM已用内存展示并监控堆内存和Metaspace重要
4jvm.buffer.memory.usedJVM缓冲区已用内存   
5jvm.buffer.count当前缓冲区数   
6jvm.threads.daemonJVM守护线程数显示在监控页面 
7jvm.threads.liveJVM当前活跃线程数显示在监控页面;监控达到阈值时报警重要
8jvm.threads.peakJVM峰值线程数显示在监控页面 
9jvm.classes.loaded加载classes数   
10jvm.classes.unloaded未加载的classes数   
11jvm.gc.memory.allocatedGC时,年轻代分配的内存空间   
12jvm.gc.memory.promotedGC时,老年代分配的内存空间   
13jvm.gc.max.data.sizeGC时,老年代的最大内存空间   
14jvm.gc.live.data.sizeFullGC时,老年代的内存空间   
15jvm.gc.pauseGC耗时显示在监控页面 
---TOMCAT---   
16tomcat.sessions.createdtomcat已创建session数   
17tomcat.sessions.expiredtomcat已过期session数   
18tomcat.sessions.active.currenttomcat活跃session数   
19tomcat.sessions.active.maxtomcat最多活跃session数显示在监控页面,超过阈值可报警或者进行动态扩容重要
20tomcat.sessions.alive.max.secondtomcat最多活跃session数持续时间   
21tomcat.sessions.rejected超过session最大配置后,拒绝的session个数显示在监控页面,方便分析问题 
22tomcat.global.error错误总数显示在监控页面,方便分析问题 
23tomcat.global.sent发送的字节数   
24tomcat.global.request.maxrequest最长时间   
25tomcat.global.request全局request次数和时间   
26tomcat.global.received全局received次数和时间   
27tomcat.servlet.requestservlet的请求次数和时间   
28tomcat.servlet.errorservlet发生错误总数   
29tomcat.servlet.request.maxservlet请求最长时间   
30tomcat.threads.busytomcat繁忙线程显示在监控页面,据此检查是否有线程夯住 
31tomcat.threads.currenttomcat当前线程数(包括守护线程)显示在监控页面重要
32tomcat.threads.config.maxtomcat配置的线程最大数显示在监控页面重要
33tomcat.cache.accesstomcat读取缓存次数   
34tomcat.cache.hittomcat缓存命中次数   
---CPU...---   
35system.cpu.countCPU数量   
36system.load.average.1mload average超过阈值报警重要
37system.cpu.usage系统CPU使用率   
38process.cpu.usage当前进程CPU使用率超过阈值报警 
39http.server.requestshttp请求调用情况显示10个请求量最大,耗时最长的URL;统计非200的请求量重要
40process.uptime应用已运行时间显示在监控页面 
41process.files.max允许最大句柄数配合当前打开句柄数使用 
42process.start.time应用启动时间点显示在监控页面 
43process.files.open当前打开句柄数监控文件句柄使用率,超过阈值后报警重要

附录

SpringBoot1.x的metrics信息

 
  1. {

  2. "mem":568029,

  3. "mem.free":164376,

  4. "processors":16,

  5. "instance.uptime":223643888,

  6. "uptime":223835542,

  7. "systemload.average":0.18,

  8. "heap.committed":415232,

  9. "heap.init":419840,

  10. "heap.used":250855,

  11. "heap":415232,

  12. "nonheap.committed":156480,

  13. "nonheap.init":2496,

  14. "nonheap.used":152797,

  15. "nonheap":0,

  16. "threads.peak":114,

  17. "threads.daemon":99,

  18. "threads.totalStarted":234,

  19. "threads":113,

  20. "classes":15474,

  21. "classes.loaded":15474,

  22. "classes.unloaded":0,

  23. "gc.ps_scavenge.count":1808,

  24. "gc.ps_scavenge.time":99224,

  25. "gc.ps_marksweep.count":3,

  26. "gc.ps_marksweep.time":5314

  27. }

  28.  

SpringBoot2.0的metrics信息

 
  1. {

  2. "names":[

  3. "jvm.memory.committed",

  4. "http.server.requests",

  5. "jvm.buffer.memory.used",

  6. "jvm.gc.memory.allocated",

  7. "tomcat.sessions.created",

  8. "tomcat.sessions.expired",

  9. "jvm.memory.used",

  10. "tomcat.global.error",

  11. "jvm.gc.max.data.size",

  12. "system.cpu.count",

  13. "jvm.memory.max",

  14. "tomcat.global.sent",

  15. "jvm.buffer.total.capacity",

  16. "jvm.buffer.count",

  17. "process.files.max",

  18. "jvm.threads.daemon",

  19. "process.start.time",

  20. "tomcat.sessions.active.max",

  21. "tomcat.global.request.max",

  22. "jvm.gc.live.data.size",

  23. "process.files.open",

  24. "process.cpu.usage",

  25. "tomcat.threads.current",

  26. "tomcat.servlet.request",

  27. "jvm.gc.pause",

  28. "process.uptime",

  29. "tomcat.threads.busy",

  30. "system.load.average.1m",

  31. "tomcat.cache.hit",

  32. "tomcat.global.request",

  33. "tomcat.servlet.error",

  34. "tomcat.servlet.request.max",

  35. "tomcat.cache.access",

  36. "tomcat.sessions.active.current",

  37. "system.cpu.usage",

  38. "jvm.threads.live",

  39. "jvm.classes.loaded",

  40. "jvm.classes.unloaded",

  41. "jvm.threads.peak",

  42. "tomcat.threads.config.max",

  43. "jvm.gc.memory.promoted",

  44. "tomcat.sessions.rejected",

  45. "tomcat.global.received",

  46. "tomcat.sessions.alive.max"

  47. ]

  48. }

转载地址:https://blog.csdn.net/jsun999/article/details/82699037

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值