Scrape data from Prometheus
The following configuration example shows how you configure a Collector instance to scrape data from an existing Prometheus setup and import it as OTLP request into Dynatrace.
Prerequisites
- A Prometheus instance running on port 8888
- One of the following Collector distributions with the Prometheus receiver and the delta conversion processor:
- The Dynatrace Collector
- OpenTelemetry Contrib
- A custom Builder version
- The Dynatrace API endpoint URL to which the data should be exported
- An API token with the relevant access scope (only required for SaaS and ActiveGate)
Demo configuration
receivers:prometheus:config:scrape_configs:- job_name: 'node-exporter'scrape_interval: 60sstatic_configs:- targets: ['prometheus-prometheus-node-exporter:9100']- job_name: opentelemetry-collectorscrape_interval: 60sstatic_configs:- targets:- 127.0.0.1:8888processors:cumulativetodelta:exporters:otlphttp:endpoint: ${env:DT_ENDPOINT}headers:Authorization: "Api-Token ${env:DT_API_TOKEN}"service:pipelines:metrics:receivers: [prometheus]processors: [cumulativetodelta]exporters: [otlphttp]
Validate your settings to avoid any configuration issues.
Components
For our configuration, we configure the following components.
Receivers
Under receivers
, we specify the prometheus
receiver as active receiver component for our Collector instance. We configure the receiver with the two jobs node-exporter
and opentelemetry-collector
under scrape_configs
, to fetch data from the specified hosts once a minute (scrape_interval: 60s
).
For a full list of configuration parameters, see the Prometheus documentation.
Processors
Under processors
, we specify the cumulativetodelta
processor to convert the metrics emitted by the Prometheus receiver to their delta aggregation format.
Exporters
Under exporters
, we specify the default otlphttp
exporter and configure it with our Dynatrace API URL and the required authentication token.
For this purpose, we set the following two environment variables and reference them in the configuration values for endpoint
and Authorization
.
DT_ENDPOINT
contains the base URL of your ActiveGate (for example,https://{your-environment-id}.live.dynatrace.com/api/v2/otlp
)DT_API_TOKEN
contains the API token
Service pipeline
Under service
, we assemble our receiver, processor, and exporter objects into a metrics pipeline, which will execute the Prometheus jobs, convert their metrics to delta values, and ingest the data into Dynatrace.
Limits and limitations
Metrics are ingested using the OpenTelemetry protocol (OTLP) via the Dynatrace OTLP API and are subject to the API's limits and restrictions. For more information see: