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
Copy file name to clipboardExpand all lines: src/docs/implementations/dynatrace.adoc
+29-16Lines changed: 29 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,6 @@ Use the following code in your project to export Micrometer metrics to the https
21
21
[source,java]
22
22
----
23
23
DynatraceConfig dynatraceConfig = new DynatraceConfig() {
24
-
@Override
25
-
public DynatraceApiVersion apiVersion() {
26
-
return DynatraceApiVersion.V2;
27
-
}
28
-
29
24
@Override
30
25
@Nullable
31
26
public String get(String k) {
@@ -34,8 +29,26 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
34
29
}
35
30
};
36
31
MeterRegistry registry = new DynatraceMeterRegistry(dynatraceConfig, Clock.SYSTEM);
32
+
Metrics.addRegistry(registry);
37
33
----
38
34
35
+
It is also possible to specify the exporter version explicitly, which defaults to `v2` unless a deviceId is set:
36
+
37
+
[source,java]
38
+
----
39
+
DynatraceConfig dynatraceConfig = new DynatraceConfig() {
40
+
@Override
41
+
public DynatraceApiVersion apiVersion() {
42
+
return DynatraceApiVersion.V2;
43
+
}
44
+
45
+
@Override
46
+
@Nullable
47
+
public String get(String k) { return null; }
48
+
};
49
+
----
50
+
51
+
39
52
`DynatraceConfig` is an interface with a set of default methods.
40
53
Micrometer's Spring Boot support binds properties prefixed with `management.metrics.export.dynatrace` directly to the `DynatraceConfig`.
41
54
This allows configuring the Dynatrace exporter by using the <<bookmark-available-properties, the available properties>>.
@@ -45,7 +58,7 @@ In this default configuration, metrics will be exported to the v2 endpoint.
45
58
46
59
=== Using a custom endpoint
47
60
48
-
If no Dynatrace OneAgent is available, both the Dynatrace Metrics API v2 endpoint and an API token have to be specified.
61
+
If no Dynatrace OneAgent is available on the host, both the Dynatrace Metrics API v2 endpoint and an API token have to be specified.
49
62
The https://www.dynatrace.com/support/help/dynatrace-api/basics/dynatrace-api-authentication/[Dynatrace API token documentation] contains more information on how to create an API token.
50
63
The 'Ingest metrics' (`metrics.ingest`) permission is required on the token in order to ingest metrics.
51
64
It is recommended to limit scope to only this permission.
@@ -55,6 +68,7 @@ It is recommended to limit scope to only this permission.
55
68
DynatraceConfig dynatraceConfig = new DynatraceConfig() {
56
69
@Override
57
70
public DynatraceApiVersion apiVersion() {
71
+
// not strictly required, but makes the code more clear.
58
72
return DynatraceApiVersion.V2;
59
73
}
60
74
@@ -63,6 +77,7 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
63
77
// 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].
109
-
The v2 exporter does not require any properties to be set except for the version.
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.
123
+
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].
124
+
In order to maintain backwards compatibility, when a `deviceId` is set (which is required for `v1` and not used in `v2`), `v1` is used as the default.
125
+
Otherwise, the version defaults to `v2`, and does not have to be set explicitly.
112
126
With no endpoint URL and token set, metrics will be exported to the local OneAgent endpoint.
113
127
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.
114
128
@@ -219,12 +233,11 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
219
233
220
234
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].
221
235
222
-
=== API v1 (Legacy)
236
+
=== API v1 (Legacy) [[bookmark-apiv1]]
223
237
224
238
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.
239
+
If a `deviceId` is specified, it will default to `v1` for backwards compatibility with earlier setups.
240
+
The `device-id` property is required for `v1` and not used in `v2`.
228
241
Existing setups will continue to work when updating to newer versions of Micrometer.
229
242
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.
0 commit comments