Observing Dapr Applications with Prometheus
In modern cloud-native applications, observability isn't optional—it's essential. When building distributed applications with Dapr (Distributed Application Runtime), monitoring becomes even more critical to ensure your services behave as expected. Thankfully, Dapr has built-in support for exposing metrics in Prometheus format, making it straightforward to integrate and monitor your applications.
Why Prometheus?
Prometheus is a widely adopted open-source system monitoring and alerting toolkit, especially popular in Kubernetes environments. It collects metrics via HTTP endpoints and stores them in a time-series database, allowing developers to track system health, performance, and anomalies over time.
Dapr and Metrics: A Natural Fit
Dapr automatically exposes a rich set of operational metrics for each system component:
-
Sidecar metrics (e.g., service invocation latency, pub/sub messages, state store interactions) on port
9090
. -
Control plane metrics (e.g., placement service, operator, dashboard) typically on port
9091
.
These metrics are emitted in Prometheus-compatible format and are ready to be scraped.
Setting Up Prometheus for Dapr
Here’s how to wire it up:
Deploy Prometheus: You can either run Prometheus as a pod in Kubernetes or in a standalone environment.
Configure Scrape Targets: Add Dapr services as targets in your Prometheus configuration file. Example:
scrape_configs:
- job_name: 'dapr-sidecar'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_container_port_name]
action: keep
regex: 'daprd-metrics'
Access the Metrics: Prometheus will scrape endpoints like
http://localhost:9090/metrics
(sidecar) orhttp://localhost:9091/metrics
(control plane).Visualize with Grafana: Use existing Dapr Grafana dashboards or build your own for custom insights.
Metrics You Get Out of the Box
Dapr provides several useful metrics, such as:
dapr_service_invocation_req_count
dapr_state_response_status
dapr_pubsub_publish_total
dapr_runtime_heap_alloc_bytes
These metrics help answer key questions like:
- How many requests is my app handling?
- Are any state store calls failing?
- What’s the memory footprint of my Dapr sidecar?
Conclusion
With minimal setup, you can bring deep observability to your Dapr-powered applications using Prometheus. Whether you're tracking performance, debugging latency, or building alerts, Dapr + Prometheus gives you the tools to operate with confidence in production.
Top comments (0)