Micronaut Micrometer

Provides integration between Micronaut and Micrometer

Version:

1 Introduction

This project integrates Micronaut and Micrometer, allowing metrics collection for Micronaut applications.

2 Release History

You can find a list of releases for this project (with release notes) here:

3 Metrics Endpoint

Using the CLI

If you are creating your project using the Micronaut CLI, supply one of micrometer-atlas, micrometer-graphite, micrometer-prometheus, or micrometer-statsd features to enable metrics and preconfigure the selected registry in your project:

$ mn create-app my-app --features micrometer-atlas

The metrics endpoint returns information about the "metrics" of the application. To execute the endpoint, send a GET request to /metrics. This returns the metric names registered with the MeterRegistry bean.

You can get specific metrics by using /metrics/[name], for example /metrics/jvm.memory.used. This would return something like:

Sample Metric Detail Json
{
  "name": "jvm.memory.used",
  "measurements": [
    {
      "statistic": "VALUE",
      "value": 1.45397552E8
    }
  ],
  "availableTags": [
    {
      "tag": "area",
      "values": [
        "heap",
        "nonheap"
      ]
    },
    {
      "tag": "id",
      "values": [
        "Compressed Class Space",
        "PS Survivor Space",
        "PS Old Gen",
        "Metaspace",
        "PS Eden Space",
        "Code Cache"
      ]
    }
  ]
}

You can further limit the metric by using a tag like /metrics/jvm.memory.used?tag=id:PS%20Old%20Gen.

Sample Metric Detail Json
{
  "name": "jvm.memory.used",
  "measurements": [
    {
      "statistic": "VALUE",
      "value": 1.1434488E7
    }
  ],
  "availableTags": [
    {
      "tag": "area",
      "values": [
        "heap"
      ]
    }
  ]
}

You may even use multiple or nested tags, for example /metrics/jvm.memory.used?tag=id:PS%20Old%20Gen&tag=area:heap.

Sample Metric Detail Json
{
  "name": "jvm.memory.used",
  "measurements": [
    {
      "statistic": "VALUE",
      "value": 1.1434488E7
    }
  ]
}

Configuration

Currently, the metrics endpoint is only enabled if you include the micrometer-core (or one of the typed registries such as micrometer-registry-statsd, micrometer-registry-graphite, etc.) AND the management dependencies. You must also enable the global metrics flag (true by default).

Property
micronaut:
  metrics:
    enabled: true
Gradle
dependencies {
    ...
    implementation "io.micronaut.micrometer:micronaut-micrometer-core"
    // micrometer-registry-statsd also pulls in micrometer-core so included above to verbose example
    implementation "io.micronaut.micrometer:micronaut-micrometer-registry-statsd"
    // Also required to enable endpoint
    implementation "io.micronaut:micronaut-management"
    ...
}
Maven
<dependency>
  <groupId>io.micronaut.micrometer</groupId>
  <artifactId>micronaut-micrometer-core</artifactId>
  <version>${micronaut.version}</version>
</dependency>
<!-- micrometer-registry-statsd also pulls in micrometer-core so included above to verbose example -->
<dependency>
  <groupId>io.micronaut.micrometer</groupId>
  <artifactId>micronaut-micrometer-registry-statsd</artifactId>
  <version>${micronaut.version}</version>
</dependency>
<!-- Also required to enable endpoint -->
<dependency>
  <groupId>io.micronaut</groupId>
  <artifactId>micronaut-management</artifactId>
  <version>${micronaut.version}</version>
</dependency>

To configure the metrics endpoint, supply configuration through endpoints.metrics.

Metrics Endpoint Configuration Example
endpoints:
  metrics:
    enabled: Boolean
    sensitive: Boolean

4 Metrics Concepts

Metric Concepts

Key Micrometer concepts include a MeterRegistry to register and use meters. A Meter is something that produces metrics.

A MeterRegistry can have some customizations automatically applied.

Meter Registry Configurer

  • Any bean that implements MeterRegistryConfigurer gets applied to every applicable MeterRegistry bean on creation

  • The implementation of the MeterRegistryConfigurer supports() method determines if the configurer is applied to a particular registry

    • If you want all registries to get the customization, return true

    • Otherwise, you can evaluate the registry for its class type, class hierarchy, or other criteria.

    • Remember you only get one shot for autoconfiguration; i.e. when the bean context is started.

    • However, in code you can apply additional customizations to the registry config.

MeterRegistryConfigurer Interface
/*
 * Copyright 2017-2019 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.configuration.metrics.aggregator;

import io.micrometer.core.instrument.MeterRegistry;

/**
 * Configures meter registries. This is done on bean added event so composite
 * registry can be skipped and non-composite registries can be added to composite.
 *
 * @author Christian Oestreich
 * @param <T> an instance of a meter registry that will be configured
 * @since 1.0
 */
public interface MeterRegistryConfigurer<T extends MeterRegistry> {

    /**
     * Configures a meter registry with binders, filters, etc.
     *
     * @param meterRegistry Meter Registry
     */
    void configure(T meterRegistry);

    /**
     * Determines if this configurer supports the meter registry type.
     *
     * @param meterRegistry a meter registry
     * @return boolean whether is supported
     */
    default boolean supports(T meterRegistry) {
        return true;
    }

    /**
     * @return the type parameter
     */
    Class<T> getType();
}
Example
/*
 * Copyright 2017-2019 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.docs;

import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.micronaut.configuration.metrics.aggregator.MeterRegistryConfigurer;
import io.micronaut.configuration.metrics.annotation.RequiresMetrics;
import io.micronaut.core.annotation.Order;
import io.micronaut.core.order.Ordered;
import jakarta.inject.Singleton;

@Order(Integer.MAX_VALUE)
@Singleton
@RequiresMetrics
public class SimpleMeterRegistryConfigurer implements MeterRegistryConfigurer<SimpleMeterRegistry>, Ordered {

    @Override
    public void configure(SimpleMeterRegistry meterRegistry) {
        meterRegistry.config().commonTags("key", "value");
    }

    @Override
    public Class<SimpleMeterRegistry> getType() {
        return SimpleMeterRegistry.class;
    }
}

Meter Filter

  • A meter filter can be used to determine if a Meter is to be added to the registry.

  • Any bean that implements MeterFilter will be applied to all registries when the registry is first created

You can create custom filters similar to the following inside your application. MeterFilter provides several convenience methods to help with the creation of these filters.

Example
package io.micronaut.docs;

import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micronaut.context.annotation.Bean;
import io.micronaut.context.annotation.Factory;
import jakarta.inject.Singleton;

import java.util.Collections;

@Factory
public class MeterFilterFactory {

    /**
     * Add global tags to all metrics.
     *
     * @return meter filter
     */
    @Bean
    @Singleton
    MeterFilter addCommonTagFilter() {
        return MeterFilter.commonTags(Collections.singletonList(Tag.of("scope", "demo")));
    }

    /**
     * Rename a tag key for every metric beginning with a given prefix.
     * <p>
     * This will rename the metric name http.server.requests tag value called `method` to `httpmethod`
     * <p>
     * OLD: http.server.requests ['method':'GET", ...]
     * NEW: http.server.requests ['httpmethod':'GET", ...]
     *
     * @return meter filter
     */
    @Bean
    @Singleton
    MeterFilter renameFilter() {
        return MeterFilter.renameTag("http.server.requests", "method", "httpmethod");
    }
}

Meter Binder

Meter Binders get applied to Meter Registry to mix in metrics producers. Micrometer defines several of these for cross-cutting metrics related to JVM metrics, caches, classloaders, etc. These implement MeterBinder, but they are not autowired as beans; manual wiring is required given how Micrometer is currently implemented.

Provided Binders

The following metrics currently have binders and are enabled by default. The settings listed below can disable individual metric binders if you do not wish to collect or report those metrics.

JVM Metrics

The JVM metrics bindings provide several JVM metrics.

Control Property: micronaut.metrics.binders.jvm.enabled

Table 1. Metrics provided

Name

jvm.buffer.count

jvm.buffer.memory.used

jvm.buffer.total.capacity

jvm.classes.loaded

jvm.classes.unloaded

jvm.gc.live.data.size

jvm.gc.max.data.size

jvm.gc.memory.allocated

jvm.gc.memory.promoted

jvm.memory.committed

jvm.memory.max

jvm.memory.used

jvm.threads.daemon

jvm.threads.live

jvm.threads.peak

Web Metrics

There is a default web filter provided for web metrics. All routes, status codes, methods, and exceptions are timed and counted.

Control Property: micronaut.metrics.binders.web.enabled

Filter Path

If enabled, by default the path /** is intercepted. To change which paths are run through the filter for the server, set micronaut.metrics.http.path. For the client, set micronaut.metrics.http.client.path.

Table 2. Metrics provided

Name

http.server.requests

http.client.requests

System Metrics

There are multiple metrics that can be separately toggled.

Uptime Metrics

The uptime metrics bindings provide system uptime metrics.

Control Property: micronaut.metrics.binders.uptime.enabled

Table 3. Metrics provided

Name

process.uptime

process.start.time

Processor Metrics

The processor metrics bindings provide system processor metrics.

Control Property: micronaut.metrics.binders.processor.enabled

Table 4. Metrics provided

Name

system.load.average.1m

system.cpu.usage

system.cpu.count

process.cpu.usage

File Descriptor Metrics

The file descriptor metrics bindings provide system file descriptor metrics.

Control Property: micronaut.metrics.binders.files.enabled

Table 5. Metrics provided

Name

process.files.open

process.files.max

Logback Metrics

The logging metrics bindings provide logging metrics if using Logback.

Control Property: micronaut.metrics.binders.logback.enabled

Table 6. Metrics provided

Name

logback.events

Hibernate Metrics

You can enable metrics for Hibernate by setting the hibernate.generate_statistics property to true in configuration. For example, for the default entity manager:

Enabling Hibernate Metrics

jpa:
  default:
    properties:
      hibernate:
        generate_statistics: true

Micrometer automatically exposes Hibernate statistics. See the source code for HibernateMetrics for the available metrics.

DataSource Metrics

The DataSource metrics bindings provide data source pool metrics.

Control Property: micronaut.metrics.binders.jdbc.enabled

There is a different set of pool metric names for HikariCP and other pool providers.

If you use io.micronaut.sql:micronaut-jdbc-hikari you will get additional pool metrics, as HikariCP has built-in support for meter registries.

Table 7. HikariCP Metrics Provided

Name

hikaricp.connections.idle

hikaricp.connections.pending

hikaricp.connections

hikaricp.connections.active

hikaricp.connections.creation

hikaricp.connections.max

hikaricp.connections.min

hikaricp.connections.usage

hikaricp.connections.timeout

hikaricp.connections.acquire

If you use io.micronaut.sql:micronaut-jdbc-tomcat or io.micronaut.sql:micronaut-jdbc-dbcp, you will get the following metrics

Table 8. Generic Pool Metrics provided

Name

jdbc.connections.usage

jdbc.connections.active

jdbc.connections.max

jdbc.connections.min

Netty Server Metrics

Currently, the following binders are provided to instrument Netty server:

  • EventLoopGroupFactoryBinder: Instrument and expose event loop group queues metrics; use micronaut.metrics.binders.netty.queues.enabled to toggle. Default is false. The queues' size and tasks wait and execution time are exposed.

  • ByteBufAllocatorMetricsBinder: Expose ByteBuf default allocators (UnpooledByteBufAllocator, PooledByteBufAllocator) metrics; use micronaut.metrics.binders.netty.bytebuf-allocators.enabled to toggle. Default is false. You can customize what metrics are exposed using micronaut.metrics.binders.netty.bytebuf-allocators.metrics. By default, all available metrics are exposed. These flags are supported:

    • POOLED_ALLOCATOR: expose PooledByteBufAllocator metrics,

    • UNPOOLED_ALLOCATOR: expose UnpooledByteBufAllocator metrics,

    • POOLED_ARENAS: expose PooledByteBufAllocator pooled arenas metrics (requires POOLED_ALLOCATOR),

    • POOLED_ARENAS_SUBPAGES: expose PooledByteBufAllocator pooled arenas sub pages metrics (requires POOLED_ARENAS),

    • POOLED_ARENAS_CHUNKLISTS: expose PooledByteBufAllocator pooled arenas chunk lists metrics (requires POOLED_ARENAS),

    • POOLED_ARENAS_CHUNKS: expose PooledByteBufAllocator pooled arenas chunks metrics (requires POOLED_ARENAS_CHUNKLISTS).

  • NettyMetricsPipelineBinder: Instrument Netty’s channel, use micronaut.metrics.binders.netty.channels.enabled to toggle. Default is false. The provided metrics include the channel count, current active channel count, channel error count, bytes read and written.

Adding Custom Metrics

To add metrics to your application, dependency-inject a MeterRegistry bean and use the provided methods to access counters, timers, etc.

See the Micrometer docs for more information.

Custom Metrics Example
package io.micronaut.docs;

import io.micrometer.core.instrument.MeterRegistry;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import reactor.core.publisher.Mono;

import javax.validation.constraints.NotBlank;

@Controller
class IndexController {

    private final MeterRegistry meterRegistry;

    IndexController(MeterRegistry meterRegistry) {
        this.meterRegistry = meterRegistry;
    }

    @Get("/hello/{name}")
    Mono<String> hello(@NotBlank String name) {
        meterRegistry
                .counter("web.access", "controller", "index", "action", "hello")
                .increment();
        return Mono.just("Hello " + name);
    }
}

Custom Exception Metrics

To report on response codes for custom handled exceptions, implement io.micronaut.http.HttpResponseProvider. The default value reported for an ExceptionHandler is 500.

See the Micronaut docs for more information on ExceptionHandler.

ExceptionHandler Reporting Example
package io.micronaut.docs;

import io.micronaut.http.HttpResponse;
import io.micronaut.http.HttpResponseProvider;

public class OutOfStockException extends RuntimeException implements HttpResponseProvider {

    @Override
    public HttpResponse<?> getResponse() {
        return HttpResponse.ok(0);
    }
}

5 Metrics Annotations

You can use the Micrometer @Timed and @Counted annotations on any bean method by adding the micronaut-micrometer-annotation dependency to your annotation processor classpath:

annotationProcessor("io.micronaut.micrometer:micronaut-micrometer-annotation")
<annotationProcessorPaths>
    <path>
        <groupId>io.micronaut.micrometer</groupId>
        <artifactId>micronaut-micrometer-annotation</artifactId>
    </path>
</annotationProcessorPaths>

6 Metrics Registries & Reporters

Metrics Registries & Reporters

By default, there is a /metrics endpoint configured, and metrics are provided to it for viewing or retrieving via HTTP. To register a specific type of reporter, include a typed registry configuration. The following are the currently supported libraries for reporting metrics.

6.1 AppOptics Registry

You can include the AppOptics reporter via io.micronaut.micrometer:micronaut-micrometer-registry-appoptics

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-appoptics")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-appoptics</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.appoptics. The most commonly changed configuration properties are listed below, but see AppOpticsConfig for more options.

Name

Description

enabled

Whether to enable the reporter. Could disable to local dev for example. Default: true

apiToken

AppOptics API token. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

uri

The URI for the AppOptics backend. Default: https://api.appoptics.com/v1/measurements

Example AppOptics Config
micronaut:
  metrics:
    enabled: true
    export:
      appoptics:
        enabled: true
        apiToken: ${APPOPTICS_API_TOKEN}
        uri: https://api.appoptics.com/v1/measurements
        step: PT1M

6.2 Atlas Registry

You can include the Atlas reporter via io.micronaut.micrometer:micronaut-micrometer-registry-atlas

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-atlas")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-atlas</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.atlas. The most commonly changed configuration properties are listed below, but see AtlasConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

uri

The URI for the Atlas backend. Default: http://localhost:7101/api/v1/publish

Example Atlas Config
micronaut:
  metrics:
    enabled: true
    export:
      atlas:
        enabled: true
        uri: http://localhost:7101/api/v1/publish
        step: PT1M

6.3 Azure Monitor Registry

You can include the Azure Monitor reporter via io.micronaut.micrometer:micronaut-micrometer-registry-azure-monitor

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-azure-monitor")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-azure-monitor</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.azuremonitor. The most commonly changed configuration properties are listed below, but see AzureMonitorConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

instrumentationKey

Azure Monitor instrumentation key. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

Example Azure Monitor Config
micronaut:
  metrics:
    enabled: true
    export:
      azuremonitor:
        enabled: true
        instrumentationKey: ${AZUREMONITOR_INSTRUMENTATION_KEY}
        step: PT1M

6.4 CloudWatch Registry

You can include the CloudWatch reporter via io.micronaut.micrometer:micronaut-micrometer-registry-cloudwatch

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-cloudwatch")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-cloudwatch</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.cloudwatch. The most commonly changed configuration properties are listed below, but see CloudWatchConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

namespace

Namespace that will be displayed in CloudWatch for these metrics. Default: micronaut.

batchSize

Number of metrics to send in a batch to CloudWatch. Default: 20. Matches max limit found on Cloudwatch API Reference.

Example CloudWatch Config
micronaut:
  metrics:
    enabled: true
    export:
      cloudwatch:
        enabled: true
        namespace: myAwesomeAppMetrics
        batchSize: 10

6.5 Datadog Registry

You can include the Datadog reporter via io.micronaut.micrometer:micronaut-micrometer-registry-datadog

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-datadog")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-datadog</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.datadog. The most commonly changed configuration properties are listed below, but see DatadogConfig for more options.

Name

Description

apiKey

Datadog API Key. Required.

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to Datadog. Disable to minimize the amount of data sent on each scrape. Default: true

Example Datadog Config
micronaut:
  metrics:
    enabled: true
    export:
      datadog:
        apiKey: ${DATADOG_APIKEY}
        enabled: true
        step: PT1M

6.6 Dynatrace Registry

You can include the Dynatrace reporter via io.micronaut.micrometer:micronaut-micrometer-registry-dynatrace

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-dynatrace")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-dynatrace</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.dynatrace. The most commonly changed configuration properties are listed below, but see DynatraceConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

apiToken

Dynatrace API Token. Required.

uri

Dynatrace server URI. Required.

decideId

Device ID to be reported. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example Dynatrace Config
endpoints:
  prometheus:
    sensitive: false
micronaut:
  metrics:
    enabled: true
    export:
      dynatrace:
        enabled: true
        apiToken: ${DYNATRACE_DEVICE_API_TOKEN}
        uri: ${DYNATRACE_DEVICE_URI}
        deviceId: ${DYNATRACE_DEVICE_ID}
        step: PT1M

6.7 Elasticsearch Registry

You can include the Elasticsearch reporter via io.micronaut.micrometer:micronaut-micrometer-registry-elastic

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-elastic")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-elastic</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.elastic. The most commonly changed configuration properties are listed below, but see ElasticConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

Example Elastic Config
micronaut:
  metrics:
    enabled: true
    export:
      elastic:
        enabled: true
        step: PT1M

6.8 Ganglia Registry

You can include the Ganglia reporter via io.micronaut.micrometer:micronaut-micrometer-registry-ganglia

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-ganglia")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-ganglia</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.ganglia. The most commonly changed configuration properties are listed below, but see GangliaConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

protocolVersion

Ganglia protocol version (3.0 or 3.1). Default: 3.1. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

Example Ganglia Config
micronaut:
  metrics:
    enabled: true
    export:
      ganglia:
        enabled: true
        protocolVersion: 3.1
        step: PT1M

6.9 Graphite Registry

You can include the Graphite reporter via io.micronaut.micrometer:micronaut-micrometer-registry-graphite

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-graphite")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-graphite</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.graphite. The most commonly changed configuration properties are listed below, but see GraphiteConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

host

The Graphite server location. Default: localhost

port

The Graphite server port. Default: 2004

Example Graphite Config
micronaut:
  metrics:
    enabled: true
    export:
      graphite:
        enabled: true
        step: PT1M
        host: localhost
        port: 2004

6.10 Humio Registry

You can include the Humio reporter via io.micronaut.micrometer:micronaut-micrometer-registry-humio

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-humio")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-humio</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.humio. The most commonly changed configuration properties are listed below, but see HumioConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

Example Humio Config
micronaut:
  metrics:
    enabled: true
    export:
      humio:
        enabled: true
        step: PT1M

6.11 Influx Registry

You can include the Influx reporter via io.micronaut.micrometer:micronaut-micrometer-registry-influx

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-influx")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-influx</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.influx. The most commonly changed configuration properties are listed below, but see InfluxConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example Influx Config
micronaut:
  metrics:
    enabled: true
    export:
      influx:
        enabled: true
        step: PT1M

6.12 JMX Registry

You can include the JMX reporter via io.micronaut.micrometer:micronaut-micrometer-jmx

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-jmx")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-jmx</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.jmx. The most commonly changed configuration properties are listed below, but see JmxConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

Example JMX Config
micronaut:
  metrics:
    enabled: true
    export:
      jmx:
        enabled: true
        step: PT1M

6.13 Kairos Registry

You can include the Kairos reporter via io.micronaut.micrometer:micronaut-micrometer-registry-kairos

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-kairos")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-kairos</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.kairos. The most commonly changed configuration properties are listed below, but see KairosConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

uri

Kairos server URI. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example Kairos Config
micronaut:
  metrics:
    enabled: true
    export:
      kairos:
        enabled: true
        uri: http://localhost:8080/api/v1/datapoints
        step: PT1M

6.14 New Relic Registry

You can include the New Relic reporter via io.micronaut.micrometer:micronaut-micrometer-registry-new-relic

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-new-relic")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-new-relic</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.newrelic. The most commonly changed configuration properties are listed below, but see NewRelicConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

apiKey

New Relic API key. Required.

accountId

New Relic account ID. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example New Relic Config
micronaut:
  metrics:
    enabled: true
    export:
      newrelic:
        enabled: true
        apiKey: ${NEWRELIC_API_KEY}
        accountId: ${NEWRELIC_ACCOUNT_ID}
        step: PT1M

6.15 New Relic Telemetry Registry

A New Relic Registry using New Relic’s own Micrometer Registry rather than the New Relic registry provided by the Micrometer project.

You can include the New Relic Telemetry reporter via io.micronaut.micrometer:micronaut-micrometer-registry-new-relic-telemetry

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-new-relic-telemetry")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-new-relic-telemetry</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.newrelic. The most commonly changed configuration properties are listed below, but see NewRelicRegistryConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

apiKey

New Relic API key. Required.

serviceName

The service name this registry will report as in New Relic.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

Example New Relic Telemetry Config
micronaut:
  metrics:
    enabled: true
    export:
      newrelic:
        enabled: true
        apiKey: ${NEWRELIC_API_KEY}
        serviceName: My Micronaut Service
        step: PT1M

6.16 Prometheus Registry

You can include the Prometheus reporter via io.micronaut.micrometer:micronaut-micrometer-registry-prometheus

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-prometheus")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-prometheus</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.prometheus. The most commonly changed configuration properties are listed below, but see PrometheusConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to Prometheus. Disable to minimize the amount of data sent on each scrape. Default: true

Example Prometheus Config
endpoints:
  prometheus:
    sensitive: false
micronaut:
  metrics:
    enabled: true
    export:
      prometheus:
        enabled: true
        step: PT1M
        descriptions: true

IMPORTANT NOTE: Once configured, the Prometheus-compatible metrics can be accessed from the path /prometheus. By default, Prometheus looks for /metrics, but that path serves the core Micronaut metrics, hence the need to point to /prometheus.

Prometheus Default Metrics

By default, there is a set of metrics that are exposed by the different binders. If you include the Prometheus reporter, those metrics will be available in Prometheus format as well.

Here you will find the definition of all default metrics exposed by a binder.

Web Metrics
Table 1. Metrics provided

Name

Description

http_client_requests_seconds_count

Total number of requests per second your application made to an endpoint via HTTP Client interface

http_client_requests_seconds_sum

Sum of the duration of every request your application made to an endpoint via HTTP Client interface

http_client_requests_seconds_max

Maximum request duration during a time window. The value resets to 0 when a new time window starts. The default time window is two minutes.

http_server_requests_seconds_count

Total number of requests your application received at an endpoint

http_server_requests_seconds_sum

Sum of the duration of every request your application received at an endpoint

http_server_requests_seconds_max

Maximum request duration during a time window. The value resets to 0 when a new time window starts. The default time window is two minutes

6.17 SignalFx Registry

You can include the SignalFx reporter via io.micronaut.micrometer:micronaut-micrometer-registry-signalfx

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-signalfx")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-signalfx</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.signalfx. The most commonly changed configuration properties are listed below, but see SignalFxConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

accessToken

SignalFX access token. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example SignalFx Config
micronaut:
  metrics:
    enabled: true
    export:
      signalfx:
        enabled: true
        accessToken: ${SIGNALFX_API_TOKEN}
        step: PT1M

6.18 Stackdriver Registry

You can include the Stackdriver reporter via io.micronaut.micrometer:micronaut-micrometer-registry-stackdriver

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-stackdriver")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-stackdriver</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.stackdriver. The most commonly changed configuration properties are listed below, but see StackdriverConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

projectId

Stackdriver Project ID. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example Stackdriver Config
micronaut:
  metrics:
    enabled: true
    export:
      stackdriver:
        enabled: true
        projectId: ${STACKDRIVER_PROJECT_ID}
        step: PT1M

6.19 StatsD Registry

You can include the StatsD reporter via io.micronaut.micrometer:micronaut-micrometer-registry-statsd

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-statsd")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-statsd</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.statsd. The most commonly changed configuration properties are listed below, but see StatsdConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

flavor

The type of metric to use (datadog, etsy or telegraf). Default: datadog

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

host

The StatsD server. Default: localhost

port

The StatsD port. Default: 8125

Example Statsd Config
micronaut:
  metrics:
    enabled: true
    export:
      statsd:
        enabled: true
        flavor: datadog
        step: PT1M
        host: localhost
        port: 8125

6.20 Wavefront Registry

You can include the Wavefront reporter via io.micronaut.micrometer:micronaut-micrometer-registry-wavefront

implementation("io.micronaut.micrometer:micronaut-micrometer-registry-wavefront")
<dependency>
    <groupId>io.micronaut.micrometer</groupId>
    <artifactId>micronaut-micrometer-registry-wavefront</artifactId>
</dependency>

You can configure this reporter using micronaut.metrics.export.wavefront. The most commonly changed configuration properties are listed below, but see WavefrontConfig for more options.

Name

Description

enabled

Whether to enable the reporter, for example per-environment or for local development. Default: true

apiToken

Wavefront API token. Required.

uri

Wavefront service URI. Required.

step

How frequently to report metrics. Default: PT1M (1 min). See java.time.Duration#parse(CharSequence)

descriptions

Whether meter descriptions should be sent to InfluxDB. Disable to minimize the amount of data sent on each scrape. Default: true

Example Wavefront Config
micronaut:
  metrics:
    enabled: true
    export:
      wavefront:
        enabled: true
        apiToken: ${WAVEFRONT_API_TOKEN}
        uri: https://longboard.wavefront.com
        step: PT1M

7 Repository

You can find the source code of this project in this repository: