Send metrics via OTLP (OpenTelemetry Protocol) metrics exporter
To export your application metrics to Dynatrace using the OTLP metrics exporter
- Add the OTLP exporter library as a dependency to your application.
- Register and configure the exporter through the OpenTelemetry SDK.
OTLP Metrics endpoint
Configure your exporter to send metrics to your Dynatrace environment URL and an API token with the Ingest metrics permission. We recommend that you limit the token scope to only this permission.
- To learn how to obtain an API token, see Tokens and authentication
- To determine your metric ingestion endpoint, see Export with OTLP
- To learn how to send metrics from your application via OTLP to the Collector, see Send metrics via the OpenTelemetry Collector
Example - Install the OTLP metrics exporter using NPM
The following is an example of setting up the exporter in JavaScript. Note that the url
and <TOKEN>
fields are only examples.
npm install --save @opentelemetry/exporter-metrics-otlp-proto
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto');// configure API endpoint and authentication tokenconst exporter = new OTLPMetricExporter({// directly in code for illustration purpose only. Consider using environment variablesurl: "https://myenv123.live.dynatrace.com/api/v2/otlp/v1/metrics",headers: {Authorization: "Api-Token <TOKEN>"},temporalityPreference: AggregationTemporality.DELTA});