Monitoring with metrics
With Open Liberty, two types of metrics are available to monitor your applications, REST endpoint-style metrics that are provided by MicroProfile Metrics, and Java Management Extensions (JMX) metrics.
MicroProfile Metrics can be accessed by monitoring tools, such as Prometheus, and by any client that’s capable of making REST requests. JMX metrics are suitable for use by Java-based monitoring tools that can communicate with JMX servers, or by custom JMX clients.
The MicroProfile Metrics feature provides a
/metrics REST interface that conforms to the MicroProfile Metrics specification.
Open Liberty uses MicroProfile Metrics to expose metrics that describe the internal state of many Open Liberty components.
Developers can also use the MicroProfile Metrics API to expose metrics from their applications.
Metrics come in various forms that include counters, gauges, timers, histograms, and meters.
You can access MicroProfile Metrics by enabling the MicroProfile Metrics feature.
Real-time values of all metrics are available by calling the
For more information about adding these metrics to your applications, see Microservice observability with metrics.
For a list of all REST endpoint-style metrics that are available for Open Liberty, see the metrics reference list.
/metrics endpoint provides two output formats.
The format that each response uses depends on the HTTP accept header of the corresponding request.
Prometheus format is a representation of the metrics that is compatible with the Prometheus monitoring tool, which is an open source metrics scraper, data store, and basic visualization tool.
This format is returned for requests with a
text/plain accept header.
JSON format is a JSON representation of the metrics.
This format is returned for requests with an
application/json accept header.
The following table displays the different endpoints that can be accessed to provide metrics in Prometheus or JSON format with a GET request:
Returns all registered metrics.
Returns metrics that are registered for the specified scope.
Returns metrics that match the metric name for the specified scope.
You can access JMX metrics by enabling the Performance Monitoring feature. After you add this feature to your server configuration, JMX metrics are automatically monitored. The Performance Monitoring feature provides MXBeans that you can use with monitoring tools that use JMX, such as JConsole.
JConsole is a graphical monitoring tool that you can use to monitor JVM and Java applications. After you enable monitoring for Open Liberty, you can use JConsole to connect to the JVM and view performance data by clicking attributes of the MXBeans. You can also use other products that consume JMX metrics to view your metrics information. For a list of all JMX metrics that are available for Open Liberty, see the JMX metrics reference list.
The MicroProfile Metrics feature provides basic metrics about the JVM and about metrics that are added to applications by using the MicroProfile Metrics API. However, the MicroProfile Metrics feature doesn’t provide metrics about Open Liberty server components unless it’s used along with the Performance Monitoring feature.
If you enable both the MicroProfile Metrics and Performance Monitoring features, then the MXBeans for monitoring and the
/metrics REST endpoint are activated.
In this case, metrics for Open Liberty server components are exposed through both interfaces.
The MicroProfile Metrics feature version 2.3 and later automatically enables the Performance Monitoring feature.