How-To: Set up Azure Monitor to search logs and collect metrics
- Make sure that omsagents are running
You can use to enable prometheus metrics endpoint scrape.
If you installed Dapr to the different namespace, you need to change the array values. For example:
...
prometheus-data-collection-settings: |-
[prometheus_data_collection_settings.cluster]
interval = "1m"
monitor_kubernetes_pods_namespaces = ["dapr-system", "default"]
[prometheus_data_collection_settings.node]
interval = "1m"
...
Apply config map:
- Install Dapr with enabling JSON-formatted logs
- Enable JSON formatted log in Dapr sidecar and add Prometheus annotations.
Add dapr.io/log-as-json: "true"
annotation to your deployment yaml.
Example:
Go to Azure Monitor
Here is an example query, to parse JSON formatted logs and query logs from dapr system processes.
ContainerLog
| 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']
| sort by Time
- Search metrics
This query, queries process_resident_memory_bytes Prometheus metrics for Dapr system processes and renders timecharts
References
Last modified November 12, 2021 :