The documentation you are viewing is for Dapr v1.9 which is an older version of Dapr. For up-to-date documentation, see the latest version.

How-To: Set up Azure Monitor to search logs and collect metrics

Enable Dapr metrics and logs with Azure Monitor for Azure Kubernetes Service (AKS)


Enable Prometheus metric scrape using config map

  1. Make sure that omsagents are running
$ kubectl get pods -n kube-system
NAME                                                              READY   STATUS    RESTARTS   AGE
omsagent-75qjs                                                    1/1     Running   1          44h
omsagent-c7c4t                                                    1/1     Running   0          44h
omsagent-rs-74f488997c-dshpx                                      1/1     Running   1          44h
omsagent-smtk7                                                    1/1     Running   1          44h
  1. Apply config map to enable Prometheus metrics endpoint scrape.

You can use azm-config-map.yaml to enable prometheus metrics endpoint scrape.

If you installed Dapr to the different namespace, you need to change the monitor_kubernetes_pod_namespaces array values. For example:

  prometheus-data-collection-settings: |-
        interval = "1m"
        monitor_kubernetes_pods = true
        monitor_kubernetes_pods_namespaces = ["dapr-system", "default"]
        interval = "1m"    

Apply config map:

kubectl apply -f ./

Install Dapr with JSON formatted logs

  1. Install Dapr with enabling JSON-formatted logs
helm install dapr dapr/dapr --namespace dapr-system --set global.logAsJson=true
  1. Enable JSON formatted log in Dapr sidecar and add Prometheus annotations.

Note: OMS Agent scrapes the metrics only if replicaset has Prometheus annotations.

Add "true" annotation to your deployment yaml.


apiVersion: apps/v1
kind: Deployment
  name: pythonapp
  namespace: default
    app: python
  replicas: 1
      app: python
        app: python
      annotations: "true" "pythonapp" "true" "true" "9090" "/"


Search metrics and logs with Azure Monitor

  1. Go to Azure Monitor

  2. Search Dapr logs

Here is an example query, to parse JSON formatted logs and query logs from dapr system processes.

| extend parsed=parse_json(LogEntry)
| project Time=todatetime(parsed['time']), app_id=parsed['app_id'], scope=parsed['scope'],level=parsed['level'], msg=parsed['msg'], type=parsed['type'], ver=parsed['ver'], instance=parsed['instance']
| where level != ""
| sort by Time
  1. Search metrics

This query, queries process_resident_memory_bytes Prometheus metrics for Dapr system processes and renders timecharts

| where Namespace == "prometheus" and Name == "process_resident_memory_bytes"
| extend tags=parse_json(Tags)
| project TimeGenerated, Name, Val, app=tostring(tags['app'])
| summarize memInBytes=percentile(Val, 99) by bin(TimeGenerated, 1m), app
| where app startswith "dapr-"
| render timechart