9 Using Coherence MicroProfile Metrics

Coherence MicroProfile (MP) Metrics provides support for Eclipse MicroProfile Metrics within the Coherence cluster members. See MicroProfile Metrics. Coherence MP Metrics is a very simple module that enables you to publish Coherence metrics into the MicroProfile Metric Registries available at runtime, and adds Coherence-specific tags to all the metrics published within the process, to distinguish them on the monitoring server, such as Prometheus.

This chapter includes the following topics:

Enabling the Use of Coherence MP Metrics

To use Coherence MP Metrics, you should first declare it as a dependency in the pom.xml file.

You can declare Coherence MP Metrics as follows:
<dependency>
    <groupId>${coherence.groupId}</groupId>
    <artifactId>coherence-mp-metrics</artifactId>
    <version>${coherence.version}</version>
</dependency>

After the module becomes available in the class path, Coherence will discover the MpMetricRegistryAdapter service it provides, and use it to publish all standard Coherence metrics to the vendor registry, and any user-defined application metrics to the application registry.

All the metrics will be published as gauges, because they represent point-in-time values of various MBean attributes.

Coherence Global Tags

There could be hundreds of members in a Coherence cluster, with each member publishing potentially the same set of metrics. There could also be many Coherence clusters in the environment, possibly publishing to the same monitoring server instance. To help distinguish metrics coming from different clusters, as well as from different members of the same cluster, Coherence MP Metrics automatically adds several tags to all the metrics published within the process.

Table 9-1 Tags Used by Coherence MP Metrics

Tag Name Tag Value

cluster

The name of the cluster.

site

The site to which the member belongs (if set).

machine

The machine on which the member is present (if set).

member

The name of the member (if set).

node_id

The node ID of the member.

role

The member’s role.

Tagging ensures that the metrics published by one member do not collide with and overwrite the metrics published by other members. Tagging also helps you query and aggregate metrics based on the values of the tags above, if required.