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.
Demo configuration
1receivers:2 prometheus:3 config:4 scrape_configs:5 - job_name: 'node-exporter'6 scrape_interval: 60s7 static_configs:8 - targets: ['prometheus-prometheus-node-exporter:9100']9 - job_name: opentelemetry-collector10 scrape_interval: 60s11 static_configs:12 - targets:13 - 127.0.0.1:88881415processors:16 cumulativetodelta:1718exporters:19 otlphttp:20 endpoint: $DT_ENDPOINT/api/v2/otlp21 headers:22 Authorization: "Api-Token $DT_API_TOKEN"2324service:25 pipelines:26 metrics:27 receivers: [prometheus]28 processors: [cumulativetodelta]29 exporters: [otlphttp]
Prerequisites
A Prometheus instance running on port 8888
- Contrib distribution or a custom Builder version with the Prometheus receiver and the delta conversion processor
- The API URL of your Dynatrace environment
- An API token with the relevant access scope
Components
For our configuration, we configure the following components.
Receiver
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.
Processor
Under processors
, we specify the cumulativetodelta
processor to convert the metrics emitted by the Prometheus receiver to their delta aggregation format.
Exporter
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
)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.