Send metrics via OTLP (OpenTelemetry Protocol) metrics exporter

To export your application metrics to Dynatrace using the OTLP metrics exporter

  1. Add the OTLP exporter library as a dependency to your application.
  2. 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.

OpenTelemetry Metrics

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 token
const exporter = new OTLPMetricExporter({
// directly in code for illustration purpose only. Consider using environment variables
url: "https://myenv123.live.dynatrace.com/api/v2/otlp/v1/metrics",
headers: {
Authorization: "Api-Token <TOKEN>"
},
temporalityPreference: AggregationTemporality.DELTA
});