Learn how to view the JVM and application server metrics of a MicroProfile application.
- [Narrator] The Eclipse MicroProfile project provides a metric specification. The aim of this specification is to provide a unified way for MicroProfile servers to export monitoring data and to include the Java API. The Java API allows application developers to expose their telemetry data. There have been multiple releases, with the most recent being 1.1. The MicroProfile Metric specification provides known rest-endpoints and some required metrics. The metrics-endpoint can either return either a JSON format or an OpenMetrics format. The OpenMetrics format is used by tools like Prometheus, so this is normally the preferential choice. It is worth noting that this is a separate specification to MicroProfile health check. This is due to the two serving fundamentally different purposes. The health check is restricted to a simple yes/no check to see if an application is generally healthy. The metrics specification aims to provide data that is not just for monitoring the health of the the application. This data also helps to identify trends to inform capacity planning, or for you to identify future issues. We will now look at how you can access metrics in your MicroProfile application. We will start with the application that is in the exercise files. Take a look a the server.xml. Here you can see that we've already got microprofile-2.2 enabled. This actually includes the metric specification, so you don't have to add any more features to enable it. What we will do, is turn off authentication for the metrics-endpoint. This is just for demo purposes, and isn't recommended in a production system. But to do it, you type, mpMetrics authentication equals false. This will just mean that we can use the httpEndpoint, not the httpsEndpoint to access metrics, and we don't have to sign in. So now that we've made the small update let's build and run the application. So we build it using mvn install. Now that this has finished building, we can run it using mvn liberty run. Once the application has started it prints out this message, the default server is ready to run a smarter planet. And you can also see it's pulled in microProfile metrics. The logs also list the available endpoints, and you can see there's a metrics endpoint already ready to use. So if we go across to a browser and open local host 9080 slash metrics. You can see that we've got loads of metrics available. These are all of the base metrics that have been provided by open liberty and the microProfile metrics specification.
- Installing Docker
- Running an application with Docker
- Deploying an application to Kubernetes
- Adding custom metrics
- Collecting and visualizing metrics
- Enabling distributed tracing