tables and logic required to find the specified metrics for the kubernetes ,container services(Resource)

Kommu, Ramesh 40 Reputation points
2024-11-26T12:31:20.49+00:00

Hello,

I would like to calculate the following metrics for AKS and Container Services:

  1. SuccessfulRuns - The count of successful runs.
  2. FailedRuns - The count of unsuccessful runs.
  3. ExecutionTime - The time taken to complete a run or operation.
  4. Availability - This measures the system's uptime, downtime, and mean time to recovery (MTTR).
  5. IOUsage - The amount of data read from or written to disk or other input/output devices during the run or operation.
  6. ResponseTime - The time taken for the system to respond to requests.
  7. MemoryUsage - The amount of memory consumed during the operation.
  8. CpuUsage - The CPU consumption during the run.
  9. Concurrency - The number of concurrent operations or processes running.

Could you please help me with the KQL queries to calculate these metrics and specify the relevant log tables for each?

Thank you!

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,363 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Pranay Reddy Madireddy 885 Reputation points Microsoft Vendor
    2024-11-27T00:33:59.0666667+00:00

    Hi Kommu, Ramesh

    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

    https://www.buchatech.com/2019/01/monitoring-azure-kubernetes-service-aks-with-azure-monitor-log-analytics/

    If you have any further queries, do let us know.


    If the answer is helpful, please click "Accept Answer" and "Upvote it".

    1 person found this answer helpful.
    0 comments No comments

  2. Kommu, Ramesh 40 Reputation points
    2024-11-28T00:30:30.7033333+00:00

    Hey Pranay,Now I got it.Thanks for the clarification


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.