Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • If you create the cache using a CacheFactory, you can call the factory's addSubregistry() method one or more times to add sub-registries to the cache it creates. See How to Add a Meter Registry when Creating a Cache, below.
  • If the cache is created for you as part of a server or locator, you can implement a custom MetricsPublishingService service that initializes your sub-registry and adds it to the cache. See How to Add a Meter Registry when Starting a Server or Locator,

Each mechanism is described in detail below.

How to Add a Meter Registry when Creating a Cache

CacheFactory provides a method which adds the given to add a meter registry to the cache's composite registry for publishing cache metrics to external monitoring systems:

...

Code Block
languagejava
themeRDark
MeterRegistry prometheusRegistry = new PrometheusMeterRegistry(...); // Create and configure your registry

Cache cache = new CacheFactory()
    .addMeterSubregistry(prometheusRegistry)
    .create();

Example adding You can call this method multiple times to add multiple meter sub-registries:

...

  1. Implement a custom metrics publishing service and put it in a jar file.
  2. Configure the jar file to register make your custom metrics publishing service discoverable.
  3. Add your jar to the classpath when you start a server or locator.

...

The new interface org.apache.geode.metrics.MetricsPublishingService provides an additional way to publish metrics generated by Micrometer meters in the cache meter registryGeode's Micrometer-based metrics. Geode discovers implementations of MetricsPublishingService during cache creation, using the standard Java ServiceLoader mechanism.

...

Package this class into a jar file.

Configure Your jar File to

...

Make Your Custom Metrics Publishing Service Discoverable

To make your service available for loadingdiscoverable, add the following provider-configuration file in the resource directory of your application jar file:

...