Is it possible to write a Kusto query for memory/CPU usage as percent of max for an Azure Container App? In the table AppPerformanceCounters I can find data on the Private Bytes and % Processor Time. But this does not seem to be what I need.
This was possible with AKS using the table Perf, which contains information such as memoryLimitBytes, cpuLimitNanoCores etc.
2
Answers
This is the answer that I got from the Microsoft support:
Hello, you cannot directly divide the metrics by total available resources in the “Metrics” tab, you can still perform calculations outside of Azure. You can write a kusto queries for instance:
Or
Unfortunately, you cannot directly run Kusto queries like the one provided inside Azure Container Apps (ACA). The query you’ve written is valid Kusto Query Language (KQL), but it is typically executed in an Azure Monitor context (such as Azure Data Explorer or Log Analytics). Which means Azure Container App is needs to configure to send telemetry data (logs and metrics) to Azure Monitor so that you can run the above commands.
I eventually found that I had already sent some data from the Container App to Log Analytics. In there I was able to go into "Live Metrics", where I could see CPU usage % (for the process) and current memory usage of my application. From there I was able to generate the following two queries which show exactly that:
So these graphs are not technically the CPU and Memory of the entire container app, but rather for the single application running in the container app. So it should be a fairly decent estimate.
If you’re looking specifically for metrics related to memory and CPU usage for Azure Container Apps, you can use the metrics explorer to investigate them, but apparently it is not supported to export these metrics to Log Analytics Workspace and perform queries there.
In LAW, you can access the app’s system and app logs indeed – https://learn.microsoft.com/en-us/azure/container-apps/log-monitoring?tabs=bash