官术网_书友最值得收藏!

  • Mastering Spring Boot 2.0
  • Dinesh Rajput
  • 213字
  • 2021-06-25 21:29:19

Exposing metrics endpoints

Spring Boot Actuator allows you to inspect some interesting parameters of your running application, such as application memory circumstances (available versus free). The following listing shows a sample of what the /metrics endpoint might give you:

{
mem: 308564,
mem.free: 219799,
processors: 4,
instance.uptime: 3912392,
uptime: 3918108,
systemload.average: -1,
heap.committed: 254976,
heap.init: 131072,
heap.used: 35176,
heap: 1847808,
nonheap.committed: 54952,
nonheap.init: 2496,
nonheap.used: 53578,
nonheap: 0,
threads.peak: 25,
threads.daemon: 23,
threads.totalStarted: 29,
threads: 25,
classes: 6793,
classes.loaded: 6793,
classes.unloaded: 0,
gc.ps_scavenge.count: 8,
gc.ps_scavenge.time: 136,
gc.ps_marksweep.count: 2,
gc.ps_marksweep.time: 208,
httpsessions.max: -1,
httpsessions.active: 0,
gauge.response.beans: 20,
gauge.response.env: 16,
gauge.response.autoconfig: 14,
gauge.response.unmapped: 1,
counter.status.200.beans: 2,
counter.login.failure: 2,
counter.login.success: 10,
counter.status.200.autoconfig: 2,
counter.status.401.unmapped: 3,
counter.status.200.env: 2
} 

As you can see, a lot of information is provided by the /metrics endpoint.

Now let's check the health of the application by using the /health endpoint:

{
  status: "UP",
  diskSpace:
  {
    status: "UP",
    total: 290391584768,
    free: 209372835840,
    threshold: 10485760
  }
} 

As you can see, the preceding information is about the health of your Spring application. Along with the basic health status, you're also given information regarding the amount of available disk space and the status of the database that the application is using.

Let's see how to expose application information by using /info endpoints.

主站蜘蛛池模板: 贺兰县| 新野县| 怀柔区| 新民市| 桐梓县| 延津县| 壶关县| 威远县| 淳安县| 白河县| 余干县| 新营市| 嘉祥县| 富裕县| 汉中市| 德化县| 北辰区| 郎溪县| 蕲春县| 喀什市| 遵化市| 泗阳县| 太和县| 大埔县| 黑水县| 澄城县| 葵青区| 广西| 特克斯县| 卓资县| 灵石县| 五莲县| 龙山县| 淮南市| 樟树市| 宁城县| 银川市| 英德市| 天津市| 龙海市| 岑巩县|