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

  • 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.

主站蜘蛛池模板: 怀安县| 泰顺县| 苏州市| 海兴县| 天柱县| 五指山市| 巴林右旗| 湖口县| 万年县| 建水县| 梨树县| 临澧县| 温泉县| 清苑县| 江达县| 什邡市| 赣州市| 哈巴河县| 连州市| 花莲市| 乌苏市| 南阳市| 广宗县| 平潭县| 大理市| 苏尼特右旗| 梁平县| 会昌县| 伽师县| 泸州市| 综艺| 巨野县| 青海省| 岫岩| 宁南县| 报价| 古蔺县| 昆山市| 卓资县| 积石山| 临潭县|