For the latest stable version, please use Micrometer 1.14.1! |
Micrometer JMX
Micrometer provides a hierarchical mapping to JMX, primarily as a cheap and portable way to view metrics locally. Where JMX exporting is found in production, the same metrics are generally exported to another, more purpose-fit monitoring system.
1. Installing
For Gradle, add the following implementation:
implementation 'io.micrometer:micrometer-registry-jmx:latest.release'
For Maven, add the following dependency:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-jmx</artifactId>
<version>${micrometer.version}</version>
</dependency>
Micrometer also sometimes scrapes data from JMX beans for use in reporting metrics. This registry implementation is not needed for these uses. Rather, this module is strictly used to export data to JMX.
2. Hierarchical name mapping
Micrometer provides a HierarchicalNameMapper
interface that governs how a dimensional meter ID is mapped to flat hierarchical names.
The default (HierarchicalNameMapper.DEFAULT
) sorts tags alphabetically by key and appends tag key/value pairs to the base meter name with '.' — for example, http_server_requests.method.GET.response.200
. The name and tag keys have the registry’s naming convention applied to them first.
If there is something special about your naming scheme that you need to honor, you can provide your own HierarchicalNameMapper
implementation. The most common cause of a custom mapper comes from a need to prefix something to the front of every metric (generally something like app.<name>.http_server_requests.method.GET.response.200
).