Metrics endpoint

The next vital part of successfully monitoring the application is through operational metrics gathering. Of course, a Spring Boot actuator covers this aspect too and provides monitoring for basic JVM characteristics such as the process uptime, memory usage, CPU usage, and GC pauses. Furthermore, WebFlux provides some statistics regarding the processing of incoming HTTP requests. However, to provide a meaningful insight into what is going on in the service from a business standpoint, we have to extend operational metrics on our own.

Starting with Spring Boot 2.0, an actuator changed an underlying library used for metrics gathering and now uses a micrometer library: https://micrometer.io.

If exposed, the /actuator/metrics REST endpoint provides a list of tracked metrics and makes it possible to navigate to a desired gauge or timer, also giving additional contextual information in the form of tags. A summary for one metric, let's say jvm.gc.pause, may look the following way:

{
"name": "jvm.gc.pause",
"measurements": [
{
"statistic": "COUNT",
"value": 5
},
{
"statistic": "TOTALTIME",
"value": 0.347
}
],
"availableTags": [
{
"tag": "cause",
"values": [
"Heap Dump Initiated GC",
"Metadata GC Threshold",
"Allocation Failure"
]
}
]
}

One drawback of the new metrics endpoint, when compared to its Spring Boot 1.x counterpart, is the inability to retrieve all the tracked metric summaries with a single REST request. However, this is probably only a minor issue.

As usual, we are free to register new metrics using a micrometer metrics registry. Later in this chapter, we will cover the mechanics of this process and will see what operational metrics are useful for the reactive application.

The /actuator/metrics endpoint is not exposed by default. Instead, the default configuration exposes only info and health endpoints. Consequently, the metrics endpoint should be exposed by providing the following property in the application.property file—management.endpoints.web.exposure.include: info, health, metrics. The same is relevant to all of the endpoints mentioned later in this chapter. In the case in which it is necessary to expose all endpoints, we may follow the next technique and provide a wildcard instead—management.endpoints.web.exposure.include: *. For more details, see the following link: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints.
..................Content has been hidden....................

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