Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
You can use KQL to calculate metrics for Azure Kubernetes Service (AKS) and Container Services by querying log tables in Azure Monitor. Here are the KQL queries for each metric and the log tables they use.
1.SuccessfulRuns
You can query the KubePodInventory table to determine the number of successful runs.
KubePodInventory
| where ContainerStatus == "Running"
| summarize SuccessfulRuns = count()
2.FailedRuns
You can also use the KubePodInventory table to count the number of unsuccessful runs.
KubePodInventory
| where ContainerStatus != "Running" and ContainerStatusReason !in ("Completed", "")
| summarize FailedRuns = count()
3.ExecutionTime
To measure execution time, you can check the logs in the ContainerLog table. By using the start and end timestamps, you can calculate how long the process took.
ContainerLog
| where LogEntry has "Start" or LogEntry has "End"
| summarize ExecutionTime = max(TimeGenerated) - min(TimeGenerated)
4.Availability
To calculate availability, you can examine the uptime and downtime in the KubePodInventory table.
KubePodInventory
| summarize Uptime = countif(ContainerStatus == "Running"), Downtime = countif(ContainerStatus != "Running")
| extend Availability = Uptime / (Uptime + Downtime)
5.IOUsage
To monitor I/O usage, query the Perf table for metrics related to disk operations.
Perf
| where ObjectName == "LogicalDisk" and CounterName in ("Disk Reads/sec", "Disk Writes/sec")
| summarize IOUsage = sum(CounterValue)
6.ResponseTime
To measure response time, review the HTTP response logs in the ContainerLog table.
ContainerLog
| where LogEntry has "HTTP"
| summarize ResponseTime = avg(ResponseTimeInMs)
7.MemoryUsage
You can query memory usage from the Perf table.
Perf
| where ObjectName == "K8SContainer" and CounterName == "Memory Working Set"
| summarize MemoryUsage = avg(CounterValue)
8.CpuUsage
CPU usage metrics can also be retrieved from the Perf table.
Perf
| where ObjectName == "K8SContainer" and CounterName == "% Processor Time"
| summarize CpuUsage = avg(CounterValue)
9.Concurrency
To measure concurrency, count the number of active pods.
KubePodInventory
| where ContainerStatus == "Running"
| summarize Concurrency = count()
For reference, please review this documentation :-
https://learn.microsoft.com/en-us/azure/azure-monitor/reference/queries/containerlog
https://learn.microsoft.com/en-us/azure/azure-monitor/reference/queries/kubepodinventory
https://learn.microsoft.com/en-us/azure/azure-monitor/reference/queries/perf
If you have any further queries, do let us know.
If the answer is helpful, please click "Accept Answer" and "Upvote it".