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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.88.62