You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For setting up new integrations with Dynatrace, it is recommended to use the latest version of the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/[Dynatrace Metrics API] (`api-version: v2`).
13
+
For setting up new integrations with Dynatrace, it is recommended to use the latest version of the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/[Dynatrace Metrics API] (v2).
14
14
Dynatrace provides different ways of setting up integrations:
15
15
16
16
=== Using a Dynatrace OneAgent installed on the host (preferred) [[bookmark-oneagent-example]]
@@ -39,13 +39,9 @@ MeterRegistry registry = new DynatraceMeterRegistry(dynatraceConfig, Clock.SYSTE
39
39
`DynatraceConfig` is an interface with a set of default methods.
40
40
Micrometer's Spring Boot support binds properties prefixed with `management.metrics.export.dynatrace` directly to the `DynatraceConfig`.
41
41
This allows configuring the Dynatrace exporter by using the <<bookmark-available-properties, the available properties>>.
42
-
To enable the export to the local OneAgent, use:
43
42
44
-
[source,yml]
45
-
----
46
-
management.metrics.export.dynatrace:
47
-
api-version: v2
48
-
----
43
+
To use the Dynatrace metrics exporter for Micrometer in your Spring Boot project, it is enough to include the `runtimeOnly 'io.micrometer:micrometer-registry-dynatrace'` dependency.
44
+
In this default configuration, metrics will be exported to the v2 endpoint.
49
45
50
46
=== Using a custom endpoint
51
47
@@ -67,13 +63,15 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
67
63
// The endpoint of the Dynatrace Metrics API v2 including path, e.g.:
When the API version is configured to "v2", the registry will send data using the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/[Metrics API v2].
107
109
The v2 exporter does not require any properties to be set except for the version.
108
-
In this case, metrics will be exported to the local OneAgent endpoint.
109
-
If no OneAgent is running on the target host, it is possible to specify an endpoint and an API token in order to export metrics to that specific endpoint.
110
+
When running Micrometer without Spring Boot, the default version is `v1` in order to maintain backwards compatibility.
111
+
The version is assumed to be `v2` automatically when using Spring Boot, and does not have to be set explicitly in that case.
112
+
With no endpoint URL and token set, metrics will be exported to the local OneAgent endpoint.
113
+
If no OneAgent is running on the target host, it is possible to specify endpoint and token explicitly, in order to export metrics to that specific endpoint.
110
114
111
115
*Minimal configuration with a local Dynatrace OneAgent*
112
116
@@ -129,45 +133,101 @@ When using the https://www.dynatrace.com/support/help/dynatrace-api/environment-
129
133
[source,yml]
130
134
----
131
135
management.metrics.export.dynatrace:
132
-
# required to use the properties below
133
-
api-version: v2
134
-
135
-
# required if not using a local OneAgent endpoint.
For more information about the metadata picked up by the enrichment, see https://www.dynatrace.com/support/help/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/enrich-metrics/[the Dynatrace documentation].
192
+
@Override
193
+
public String metricKeyPrefix() {
194
+
// will be prepended to all metric keys
195
+
return "your.desired.prefix";
196
+
}
197
+
198
+
@Override
199
+
public boolean enrichWithDynatraceMetadata() {
200
+
return true;
201
+
}
202
+
203
+
@Override
204
+
public Map<String, String> defaultDimensions() {
205
+
// create and return a map containing the desired key-value pairs.
206
+
Map<String, String> dims = new HashMap<String,String>();
207
+
dims.put("dimensionKey", "dimensionValue");
208
+
return dims;
209
+
}
210
+
211
+
@Override
212
+
@Nullable
213
+
public String get(String k) {
214
+
// This method for retrieving arbitrary config items introduced by the interface is currently not used in DynatraceConfig.
215
+
return null;
216
+
}
217
+
};
218
+
----
219
+
220
+
For more information about the metadata picked up by the Dynatrace metadata enrichment feature, see https://www.dynatrace.com/support/help/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/enrich-metrics/[the Dynatrace documentation].
165
221
166
222
=== API v1 (Legacy)
167
223
168
-
When the apiVersion is configured to "v1", the registry will send data using the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v1/custom-metrics/[Dynatrace Timeseries API v1 for custom metrics].
224
+
When the apiVersion is configured to `v1`, the registry will send data using the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v1/custom-metrics/[Dynatrace Timeseries API v1 for custom metrics].
225
+
If no `apiVersion` is specified, it will default to `v1` for backwards compatibility with earlier setups.
226
+
When using Spring Boot, `v1` can be turned on by specifying the `device-id` property, which is required for `v1` and not used in `v2`.
227
+
Therefore, when running Spring Boot with the `v1` exporter and a configuration with the required `device-id` property, metrics will be exported to the v1 API.
228
+
Existing setups will continue to work when updating to newer versions of Micrometer.
169
229
The reported metrics will be assigned to https://www.dynatrace.com/support/help/dynatrace-api/environment-api/topology-and-smartscape/custom-device-api/report-custom-device-metric-via-rest-api/[custom devices] in Dynatrace.
170
-
If no apiVersion is specified, it will default to "v1" for backwards-compatibility with earlier setups.
230
+
171
231
172
232
For the v1 API, do not specify the ingest path, but only the base URL of your environment, e.g.: `uri: https://{your-environment-id}.live.dynatrace.com`
173
233
@@ -204,14 +264,18 @@ MeterRegistry registry = new DynatraceMeterRegistry(dynatraceConfig, Clock.SYSTE
0 commit comments