Your teams already expose metrics in Prometheus format: a Redis exporter, a /metrics endpoint in every microservice, ingress metrics. Ignoring them means throwing away ready-made SLIs. Wiring Prometheus metrics, Dynatrace and your Kubernetes cluster together brings them into the same platform as traces and logs, without rewriting a line of code.

For SREs the stake is simple: a latency SLO computed from a Prometheus histogram is only worth something if it is correlated with the deployment, pod and trace that explain it. Otherwise on-call cross-checks by hand, and MTTR grows.

The goal of this tutorial: get Prometheus metrics into Dynatrace in two ways, through pod annotations read by the ActiveGate and through an OpenTelemetry Collector, then check ingestion. The content applies to Dynatrace SaaS and Dynatrace Managed; differences are flagged.

Prometheus metrics, Dynatrace and Kubernetes: two methods

Method When to choose it Limits
metrics.dynatrace.com/* annotations read by the ActiveGate Cluster already monitored by Dynatrace Operator, few exporters Documented ceilings: 1,000 exporter pods, 1,000 metrics per pod
OpenTelemetry Collector with the prometheus receiver New deployment, large cluster, need to filter or enrich One more component to run and monitor

The documentation now recommends the Collector for new deployments and for any cluster approaching the ActiveGate ceilings. Both methods can coexist during a migration, as long as the same pod is not scraped twice.

Prerequisites

  • A Kubernetes cluster and kubectl with admin rights.
  • Method 1: Dynatrace Operator deployed with an ActiveGate in the cluster; see connecting Dynatrace Operator to a cluster.
  • Method 2: an API token with the metric ingest scope (metrics.ingest), stored in a Kubernetes secret.
  • An exporter that already answers: curl http://<pod-ip>:9121/metrics must return text.

Method 1: annotations read by the ActiveGate

Step 1: enable collection

In the Kubernetes cluster monitoring settings in Dynatrace, enable monitoring of namespaces, services, workloads and pods, then the option to monitor annotated Prometheus exporters. Without that setting, annotations are ignored.

Step 2: annotate the exporter pod

apiVersion: apps/v1 kind: Deployment metadata: name: redis-exporter spec: selector: matchLabels: { app: redis-exporter } template: metadata: labels: { app: redis-exporter } annotations: metrics.dynatrace.com/scrape: "true" metrics.dynatrace.com/port: "9121" metrics.dynatrace.com/path: "/metrics" metrics.dynatrace.com/filter: | { "mode": "include", "names": ["redis_up", "redis_connected_clients", "redis_db_keys"] } spec: containers: - name: exporter image: oliver006/redis_exporter:v1.62.0 ports: - containerPort: 9121 

The critical lines: annotations go on the pod template, not on the Deployment itself. port is required, path defaults to /metrics. The filter in include mode is your volume guard: an exporter often exposes hundreds of series of which three are useful.

If a NetworkPolicy protects the namespace, allow traffic from the ActiveGate pod in the dynatrace namespace. It is the number one cause of missing metrics.

Method 2: an OpenTelemetry Collector that scrapes

Step 1: the secret

kubectl create namespace otel kubectl -n otel create secret generic dynatrace-otelcol-dt-api-credentials \ --from-literal=DT_ENDPOINT=https://<environment-id>.live.dynatrace.com/api/v2/otlp \ --from-literal=DT_API_TOKEN=<metrics-ingest-token> 

On Managed, the OTLP endpoint goes through an ActiveGate: https://<activegate>:9999/e/<environment-id>/api/v2/otlp.

Step 2: the Collector configuration

receivers: prometheus: config: scrape_configs: - job_name: redis-exporter scrape_interval: 60s kubernetes_sd_configs: - role: pod relabel_configs: - source_labels: [__meta_kubernetes_pod_label_app] action: keep regex: redis-exporter - source_labels: [__meta_kubernetes_namespace] target_label: k8s_namespace_name processors: cumulative_to_delta: max_staleness: 25h exporters: otlp_http: endpoint: ${env:DT_ENDPOINT} headers: Authorization: "Api-Token ${env:DT_API_TOKEN}" service: pipelines: metrics: receivers: [prometheus] processors: [cumulative_to_delta] exporters: [otlp_http] 

Why cumulative_to_delta: Prometheus counters are cumulative, and Dynatrace expects OTLP in delta temporality. Without this processor, counters are rejected. Details are in OTLP metric temporality. The Dynatrace documentation also adds the metric_start_time processor with its Collector distribution (v0.41.0 or later); depending on your image, the older names otlphttp and cumulativetodelta are still accepted as aliases.

The prometheus receiver with kubernetes_sd_configs needs a ServiceAccount allowed to list pods (get, list, watch). For deploying the Collector itself (Helm, RBAC, resources), follow our OpenTelemetry Collector on Kubernetes tutorial. On a large cluster a single Collector becomes a bottleneck: the OpenTelemetry Operator’s Target Allocator spreads targets across several replicas.

How to check it works

For method 2, read the Collector logs first:

kubectl -n otel logs deploy/otel-collector | grep -iE "error|scrape|refused" 

No 401 or 403 line should appear; otherwise review the token scope. The Collector also exposes its own metrics: otelcol_receiver_accepted_metric_points should keep rising.

In Dynatrace SaaS, open a notebook and chart an exporter metric:

timeseries clients = avg(redis_connected_clients) 

If the key does not appear under that name, search « redis » in the metrics explorer: depending on the ingest method and metric type, Dynatrace may add a suffix to the key (this is documented for counters, histograms and summaries). On Managed, use the data explorer with the same search.

Good practices

  • Filter at the source: an include list in method 1, metric_relabel_configs or the filter processor in method 2.
  • Keep a 60 s scrape interval unless you have a specific need: quartering the interval quadruples the volume.
  • Never scrape a pod with both methods at once: you would double the series and skew your SLOs.
  • For latency SLOs, ingest histograms and read histogram metrics with OpenPipeline.
  • Monitor the Collector itself: a scrape that fails silently looks like a service with no traffic.

Frequently asked questions

Do I need to keep a Prometheus server?

No, neither method needs one: the ActiveGate or the Collector scrapes the exporters directly. If you keep Prometheus for other uses, avoid duplicating the same series in both tools without a reason.

Do annotations work with Dynatrace Managed?

Yes, the annotation method relies on the ActiveGate and its Kubernetes module, available on Managed as on SaaS. Client authentication options (certificates, secrets) require an ActiveGate deployed inside the monitored cluster.

Why do my counters show odd values?

Dynatrace stores Prometheus counters as deltas: you see the increase between two scrapes, not the raw counter value. That is expected. On the Collector side, a counter that restarts without a correctly configured cumulative_to_delta produces gaps.

Conclusion

For a few exporters on a cluster already running Dynatrace Operator, annotations are enough. For a new cluster or large volumes, an OpenTelemetry Collector with the prometheus receiver gives more control. Either way, filter early, check the logs then DQL, and tie your SLIs to existing SLOs. The reference is on docs.dynatrace.com and, for the receiver, on opentelemetry.io.

span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of its owner. Screen names and procedures change: always check the official documentation before a production change.

Originally published on span.observer. French version: https://span.observer/fr/prometheus-dynatrace-kubernetes/.