Send Micrometer metrics to Dynatrace
Micrometer is an open source instrumentation framework for JVM-based application metrics. It's used by Spring Boot to instrument a wide range of metrics. You can ingest Micrometer and Spring Boot metrics and analyze them with Dynatrace Davis® AI end to end in the context of your trace, log, and diagnostics data. With Dynatrace, you get intelligent AI-based observability and automatic root cause analysis for Spring Boot, 15+ pre-instrumented JVM-based frameworks and servers, and custom metrics.
You can use Micrometer in Dynatrace to:
- Ingest pre-instrumented metrics from Spring Boot applications
- Ingest pre-instrumented metrics from JVM-based frameworks, servers, and cache systems
- Define and ingest custom metrics
Metrics ingested from Micrometer consume DDUs for custom metrics.
There are two ways of using Micrometer:
Prerequisites
-
Micrometer version 1.8.0+
-
optional Spring Boot version 2.6.0+
-
The registry dependency must be added to your project:
Ingestion channels
You can use one of the following ingestion channels to send your Micrometer metrics:
- OneAgent metric API—needs OneAgent installed on the monitored host.
- Metrics API v2.
Dynatrace Micrometer registry
Micrometer uses the concept of a registry to export metrics to monitoring systems.
- For Micrometer version 1.8.0 or later, Dynatrace Registry v2 is available. It exports metrics via the Metrics API v2. All new integrations of Micrometer and Dynatrace must use this version.
- For Micrometer version 1.8.0 or earlier, the legacy Dynatrace Micrometer registry v1 is available. For instructions, see Dynatrace Micrometer registry v1 (legacy) below.
Ingest metrics from Spring Boot apps
Micrometer can be configured via a .properties
or .yaml
file used for Spring Boot configuration.
Spring Boot automatically binds properties with the management.dynatrace.metrics.export
prefix to the Dynatrace configuration object.
All configuration should be made through the property files. Manually creating a Micrometer MeterRegistry
breaks the auto-configuration.
Property names for binding attributes from Spring Boot have changed in Spring Boot version 3.0.0. If you use a Spring Boot version before 3.0.0, use management.metrics.export.dynatrace
instead of management.dynatrace.metrics.export
.
Ingest metrics directly from Micrometer
Verify the metrics
After you have sent your metrics, verify the data in the Data Explorer.
Configuration properties
To set up the Dynatrace Micrometer registry, you need the Dynatrace configuration object (DynatraceConfig
). The object contains the parameters of metric ingestion and is used to construct the Dynatrace registry (DynatraceMeterRegistry
), which is registered with Micrometer to ingest metrics to Dynatrace. You can set the following parameters:
Additional information
Metric types
All metrics are transformed to follow the Metric ingestion protocol types used by Dynatrace.
Gauge
gauge,X
Counter
count,delta=X
Timer
gauge,min=X,max=Y,sum=Z,count=N
DistributionSummary
gauge,min=X,max=Y,sum=Z,count=N
LongTaskTimer
gauge,min=X,max=Y,sum=Z,count=N
TimeGauge
gauge,X
FunctionCounter
count,delta=X
FunctionTimer
gauge,min=X,max=Y,sum=Z,count=N
Meter metadata
Starting with version 1.12.0 of the Dynatrace Micrometer registry, meter metadata (unit and description) is automatically exported to Dynatrace. No code changes are required to start exporting metadata. To turn off metadata export, use the following configuration:
For previous versions of Micrometer, you need to specify the metadata manually using either the Dynatrace web UI or Dynatrace API. For more information, see Custom metric metadata.
Sending metrics from Kubernetes
OneAgent cannot be used for Micrometer metric ingestion on Kubernetes nodes. You can configure your Micrometer setup to push metrics directly to Dynatrace using the Metrics API.
Capture JVM metrics in Micrometer
By default, JVM metrics are turned off when running Micrometer without Spring Boot. To learn how to enable them, see the Micrometer documentation. After they are enabled and registered with the Dynatrace registry (DynatraceMeterRegistry
), JVM metrics are created and sent to Dynatrace automatically.
On hosts that are monitored by OneAgent, these metrics might already be captured by OneAgent.
Restrict ingestion of specific metrics
Troubleshooting with logs
Dynatrace summary instruments
Starting with Micrometer version 1.9.x, specialized instruments are used in the Dynatrace meter registry for certain summary instruments (DynatraceTimer
and DynatraceDistributionSummary
). Their purpose is to get around a peculiarity in how Micrometer records metrics, which, in some cases, led to metrics being rejected by Dynatrace for having an invalid format. The specialized instruments, tailored to Dynatrace metrics ingestion, prevent the creation of invalid metrics.
- They are available from version 1.9.0 and are used as a drop-in replacement by default. No action is needed from users upgrading to 1.9.0.
- If there's a discrepancy in the observed metrics, it's possible to return to the previous behavior by setting the
useDynatraceSummaryInstruments
toggle tofalse
.
Dynatrace Micrometer registry v1 (legacy)
If the apiVersion property is set to V1
, the registry sends data via the Timeseries API v1. For backward compatibility, it defaults to V1
if a deviceId is specified, because this property is required in V1
and is not used in V2
.
Existing setups will continue to work when updating to newer versions of Micrometer. The reported metrics will be assigned to custom devices in Dynatrace.
For the V1
API, you only need to specify the base URL of your environment (for example, https://mySampleEnv.live.dynatrace.com
).
management.dynatrace.metrics.export:# For v1 export, do not append a path to the endpoint URL. For example:# For SaaS: https://{your-environment-id}.live.dynatrace.com# For Managed deployments: https://{your-domain}/e/{your-environment-id}uri: https://{your-environment-id}.live.dynatrace.com# Should be read from a secure sourceapi-token: MY_TOKEN# When setting the device id, metrics will be exported to the v1 timeseries endpoint# Using just device-id (without the v1 prefix) is deprecated, but will work to maintain backwards compatibility.v1:device-id: sample# To disable Dynatrace publishing (for example, in a local development profile), use:# enabled: false# The interval at which metrics are sent to Dynatrace. The default is 1 minute.step: 1m
DynatraceConfig dynatraceConfig = new DynatraceConfig() {@Overridepublic String uri() {// The Dynatrace environment URI without any path. For example:// https://{your-environment-id}.live.dynatrace.comreturn MY_DYNATRACE_URI;}@Overridepublic String apiToken() {// Should be read from a secure sourcereturn MY_TOKEN;}@Overridepublic String deviceId() {return MY_DEVICE_ID;}@Override@Nullablepublic String get(String k) {return null;}};DynatraceMeterRegistry registry = DynatraceMeterRegistry.builder(config).build();// Add the Dynatrace registry to Micrometers global registry.Metrics.addRegistry(registry);