How to monitor CPU and RAM usage for a Linux VM in Azure

Cloud_Geek_82 901 Reputation points
2024-05-28T06:01:13.4133333+00:00

Hi All,

There is a Linux VM in Azure.

How to monitor its CPU and RAM usage?

For example I need to find the maximum CPU and RAM usage for a certain period of time (from 8AM till 6PM).

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,015 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 47,436 Reputation points
    2024-05-28T06:41:23.6266667+00:00
    0 comments No comments

  2. Prrudram-MSFT 28,201 Reputation points Moderator
    2024-05-29T10:36:58.6866667+00:00

    Hi @Cloud_Geek_82

    Thank you for reaching out to the Microsoft Q&A platform.

    As suggested by Olaf, to monitor the CPU and RAM usage of a Linux VM in Azure, you can use Azure Monitor. Here are the steps to find the maximum CPU and RAM usage for a certain period of time:

    1. Open the Azure portal and navigate to the virtual machine that you want to monitor.
    2. Click on the "Metrics" blade in the left-hand menu.
    3. In the "Metrics" blade, select the "Percentage CPU" metric and the "Memory Usage" metric.
    4. Set the time range to the period you want to monitor (from 8AM till 6PM).
    5. Click on the "Chart options" button and select "Max" as the aggregation type.
    6. Click on the "Apply" button to update the chart.
    7. You can now see the maximum CPU and RAM usage for the selected period of time.

    Refer to this link : https://learn.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-performance

    Alternatively, you can use the Azure Monitor REST API to collect the CPU and RAM usage data for the VM. You can use the following GET request to collect the CPU and RAM usage data: GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/microsoft.insights/metrics?api-version=2018-01-01&metricnames=Percentage CPU,Memory Usage&timespan=2018-06-05T03:00:00Z/2018-06-07T03:00:00Z Replace the {subscriptionId}, {resourceGroupName}, and {vmName} placeholders with the appropriate values for your VM. The timespan parameter specifies the period of time you want to monitor.

    https://learn.microsoft.com/en-us/azure/virtual-machines/linux/metrics-vm-usage-rest

    I hope this helps! Let me know if you have any other questions.

    If I have answered your query, please click "Accept as answer" as a token of appreciation

    0 comments No comments

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.