Send Micrometer metrics to Dynatrace
Micrometer is an open-source instrumentation framework for JVM-based application metrics. It is 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:
Prerequisite
-
Micrometer version 1.8.0+
-
optional Spring Boot version 2.6.0+
-
The register 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. The Dynatrace Registry v2 is available with Micrometer version 1.8.0 or later. 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. Find the instructions in the Dynatrace Micrometer registry v1 section.
Ingest via Spring Boot
Micrometer can be configured via a .properties
or .yaml
file used for Spring Boot configuration. Spring Boot automatically binds properties with management.metrics.export.dynatrace
to the Dynatrace configuration object.
For hosts that are monitored by OneAgent, automatic configuration is available. You don't need to specify the API endpoint to ingest the metric—if the uri parameter is not set in the configuration, the metric will be ingested via the OneAgent metric API.
To ingest metrics from hosts where OneAgent is not installed, you need to use the ingest endpoint of Metrics API v2. To learn how to use the endpoint, see POST ingest data points.
You can use the Spring placeholder notation (for example, api-token: ${DT_METRICS_INGEST_API_TOKEN}
), which will automatically read the environment variable and supply it to the Micrometer configuration.
Ingest directly from Micrometer
For hosts that are monitored by OneAgent, automatic configuration is available. You don't need to specify the API endpoint to ingest the metric—if the uri parameter is not set in the configuration, the metric will be ingested via the OneAgent metric API.
To ingest metrics from hosts where OneAgent is not installed, you need to use the ingest endpoint of Metrics API v2. To learn how to use the endpoint, see POST ingest data points.
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:
Property | Description | Required |
---|---|---|
api-version | The version of the Dynatrace API to ingest data to Dynatrace:
| optional |
uri | The ingestion endpoint of the API. | optional |
metric-key-prefix | The prefix to be added to all ingested metric keys (for example, a namespace). | optional |
enrich-with-dynatrace-metadata | Enrich ( If not set, | optional |
default-dimensions | A list of dimensions to be added to the ingested metrics. Dimensions are defined as key-value pairs. | optional |
Property | Description | Required |
---|---|---|
apiVersion | The version of the Dynatrace API to ingest data to Dynatrace:
| optional |
uri | The ingestion endpoint of the API. | optional |
metricKeyPrefix | The prefix to be added to all ingested metric keys (for example, a namespace). | optional |
enrichWithDynatraceMetadata | Enrich ( If not set, | optional |
defaultDimensions | A list of dimensions to be added to the ingested metrics. Dimensions are defined as key-value pairs. | optional |
Additional information
Metric types
All metrics are transformed to follow the Metric ingestion protocol types used by Dynatrace.
Micrometer instrument | Dynatrace metric type |
---|---|
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 |
Metric units
The ingestion protocol currently doesn't support automatic unit setting. You must specify units manually. For more information, see Custom metric metadata.
Capture JVM metrics in Micrometer
By default, JVM metrics are turned off in Micrometer. To learn how to enable them, see Micrometer documentation. Once 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
When running Micrometer in Spring Boot, many metrics are automatically created and sent to Dynatrace, including JVM, process, and disk metrics.
To see all metrics created by your Spring Boot application, navigate to the actuator endpoint on your Spring Boot app (/actuator/metrics
). Some of these metrics might already be captured by OneAgent.
Disable metrics with Spring properties
Metrics can be disabled based on their prefix in the Spring Boot configuration. To find out which metrics can be excluded, check your Spring Boot applications actuator endpoint. Be sure to exclude the metric key prefix (if any) when using this feature.
Disable metrics in code
Micrometer provides meter filters to disable metrics based on a variety of reasons. Meter filters can also be configured via Spring Boot with the @Configuration
annotation.
Note that the metric key prefix is not taken into consideration here.
Add MeterFilters before you turn on additional metrics, as the meter filter will otherwise be overridden.
You can configure the registry to filter out specific metrics by name and/or tags (for example, metrics that are already captured by OneAgent). To achieve that, use Micrometer's meter filters. You need to add meter filters before you enable capture of JVM metrics, otherwise filters will be overridden.
Metric key prefixes cannot be used for filtering.
Troubleshooting with logs
Spring handles the logging when using Micrometer in the Spring Boot context. The log level for the Micrometer Dynatrace registry can be set via configuration properties.
Dynatrace Micrometer registry v1 (legacy)
If the apiVersion property is set to V1
, the registry sends data via the Timeseries API v1. For backwards 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
).