Spring Boot 2.0 HTTP request metrics.

Spring Boot auto-configures a composite MeterRegistry and adds a registry to the composite for each of the supported implementations that it finds on the classpath. Having a dependency on micrometer-registry-{system} in your runtime classpath is enough for Spring Boot to configure the registry.
Most registries share common features. For instance, you can disable a particular registry even if the Micrometer registry implementation is on the classpath. For instance, to disable Datadog:
Spring Boot will also add any auto-configured registries to the global static composite registry on the Metrics class unless you explicitly tell it not to:
You can register any number of MeterRegistryCustomizer beans to further configure the registry, such as applying common tags, before any meters are registered with the registry:
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
 return registry -> registry.config().commonTags("region", "us-east-1");
You can apply customizations to particular registry implementations by being more specific about the generic type:
MeterRegistryCustomizer<GraphiteMeterRegistry> graphiteMetricsNamingConvention() {
 return registry -> registry.config().namingConvention(MY_CUSTOM_CONVENTION);
With that setup in place you can inject MeterRegistry in your components and register metrics:
public class SampleBean {

 private final Counter counter;

 public SampleBean(MeterRegistry registry) {
  this.counter = registry.counter("received.messages");

 public void handleMessage(String message) {
  // handle message implementation

Spring Boot also configures built-in instrumentation (i.e. MeterBinder implementations) that you can control via configuration or dedicated annotation markers.

Supported monitoring systems

54.2.1 Atlas

By default, metrics are exported to Atlas running on your local machine. The location of the Atlas server to use can be provided using:

54.2.2 Datadog

Datadog registry pushes metrics to datadoghq periodically. To export metrics to Datadog, your API key must be provided:
You can also change the interval at which metrics are sent to Datadog:

54.2.3 Ganglia

By default, metrics are exported to Ganglia running on your local machine. The Ganglia server host and port to use can be provided using:

54.2.4 Graphite

By default, metrics are exported to Graphite running on your local machine. The Graphite server host and port to use can be provided using:

54.2.5 Influx

By default, metrics are exported to Influx running on your local machine. The location of the Influx server to use can be provided using:

54.2.6 JMX

Micrometer provides a hierarchical mapping to JMX, primarily as a cheap and portable way to view metrics locally. Spring Boot provides a default HierarchicalNameMapper that governs how a dimensional meter id is mapped to flat hierarchical names.



Popular Posts