Deploy this integration to send custom metrics from your Java application to using Micrometer. The dedicated Micrometer metrics registry sends custom metrics from your Java application to your account.

Before you begin, you’ll need: Java 11 or higher

This integration currently works with Java 11 or higher. Support for earlier versions is in development and is expected later this year.

Configuring your Java applicatin to send custom metrics to

Add the Micrometer registry to your application
Via Maven

If you use Maven, add the dependency to your project configuration file (for instance, pom.xml in a Maven project) as follows:

Via Gradle

If you use Gradle, add the dependency to your project as follows:

implementation 'io.logz.micrometer:micrometer-registry-logzio:1.0'
Import in your package

To add the dependency directly to your package:

import io.micrometer.logzio.LogzioConfig;
import io.micrometer.logzio.LogzioMeterRegistry;
Initialize the Micrometer in your application code

Add the following code to your application:

package your_package;
import io.micrometer.core.instrument.*;
import io.micrometer.core.instrument.Timer;
import io.micrometer.logzio.LogzioConfig;
import io.micrometer.logzio.LogzioMeterRegistry;

class MicrometerLogzio {

   public static void main(String[] args) {
       // initilize config
      LogzioConfig logzioConfig = new LogzioConfig() {
         public String get(String key) {
            return null;
         public String uri() {
            return "<<LISTENER-HOST>>";

         public String token() {

         public Duration step() {
            return Duration.ofSeconds(<<interval>>);
      // Initialize registry
      LogzioMeterRegistry registry = new LogzioMeterRegistry(logzioConfig, Clock.SYSTEM);
      // Define tags (labels)
      ArrayList<Tag> tags = new ArrayList<>();


Replace the placeholders to match your specifics. (They are indicated by the double angle brackets << >>):

  • Replace <<PROMETHEUS-METRICS-SHIPPING-TOKEN>> with a token for the Metrics account you want to ship to.
    Here’s how to look up your Metrics token.
  • Replace <<LISTENER-HOST>> with the Listener URL for your region, configured to use port 8052 for http traffic, or port 8053 for https traffic. For example, if your account is hosted on AWS US East, or if hosted on Azure West Europe.
Add common tags to the registry

If required, you can attach common tags (“key” and “value”) to your registry. These tags will be added to all metrics reported, for example:

// Initialize registry
LogzioMeterRegistry registry = new LogzioMeterRegistry(logzioConfig, Clock.SYSTEM);
// Define tags (labels)
registry.config().commonTags("key", "value");
Add required meter binders

Micrometer provides a set of binders for monitoring Java metrics out of the box. If you want to enable a meter binder, add the metric binder code defnition to your application code, after the registry initialization. For example:

// Initialize registry
LogzioMeterRegistry registry = new LogzioMeterRegistry(logzioConfig, Clock.SYSTEM);

// Gauges buffer and memory pool utilization
new JvmMemoryMetrics().bindTo(registry);
// Gauges max and live data size, promotion and allocation rates, and times GC pauses
new JvmGcMetrics().bindTo(registry);
// Gauges current CPU total and load average.
new ProcessorMetrics().bindTo(registry);
// Gauges thread peak, number of daemon threads, and live threads
new JvmThreadMetrics().bindTo(registry);
// Gauges loaded and unloaded classes
new ClassLoaderMetrics().bindTo(registry);

// File descriptor metrics gathered by the JVM
new FileDescriptorMetrics(tags).bindTo(registry);
// Gauges The uptime and start time of the Java virtual machine
new UptimeMetrics(tags).bindTo(registry);

// Counter of logging events
new LogbackMetrics().bindTo(registry);
new Log4j2Metrics().bindTo(registry);

For the full list of available meter binders, refer to the Micrometer-core Github repo.

Add required metrics

This integration allows you to use the following metrics:

Name Behavior
Counter Metric value can only go up or be reset to 0, calculated per counter.increment(value); call.
Gauge Metric value can arbitrarily increment or decrement, values can set automaticaly by tracking Collection size or set manually by gauge.set(value)
DistributionSummary Metric values captured by the summary.record(value) function, the output is a distribution of count,sum and max for the recorded values during the push interval.
Timer Mesures timing, metric values can be recorded by timer.record() call.

Refer to the Micrometer documentation for more details on each metric.

To add a required metric to your code, copy and paste the required metric code to your application, placing it after the initialization code (or the meter binders, if present):

Counter counter = Counter
        .description("a description of what this counter does") // optional
        .tags(tags) // optional
// Increment your counter
// The following metric will be created and sent to counter_example_total{env="dev"} 3
// Create Gauge
List<String> cache = new ArrayList<>(4);
// Track list size
Gauge gauge = Gauge
        .builder("cache_size_gauge_example", cache, List::size)
// The following metric will be created and sent to cache_size_gauge_example{env="dev"} 1
// Track map size
Map<String, Integer> map_gauge = registry.gaugeMapSize("map_gauge_example", tags, new HashMap<>());
// The following metric will be created and sent to map_gauge_example{env="dev"} 1
// set value manually
AtomicInteger manual_gauge = registry.gauge("manual_gauge_example", new AtomicInteger(0));
// The following metric will be created and sent to manual_gauge_example{env="dev"} 83

// Create DistributionSummary
DistributionSummary summary = DistributionSummary
        .description("a description of what this summary does") // optional
        .tags(tags) // optional
// Record values to distributionSummary
// // The following metrics will be created and sent to 
// summary_example_count{env="dev"} 3
// summary_example_max{env="dev"} 30
// summary_example_sum{env="dev"} 60
// Create Timer
Timer timer = Timer
        .description("a description of what this timer does") // optional
        .tags(tags) // optional
// You can set a value manually
// You can record the timing of a function
timer.record(()-> {
    try {
    } catch (InterruptedException e) {
// The following metrics will be created and sent to 
// timer_example_duration_seconds_count{env="dev"} 2
// timer_example_duration_seconds_max{env="dev"} 1501
// timer_example_duration_seconds_sum{env="dev"} 3000

Run your application

Run your application to start sending metrics to

Check for your metrics

Give your metrics some time to get from your system to ours, and then open Metrics dashboard.