Hello Vinoth Kaliaperumal
To find the overall runtime of an Azure virtual machine via portal or Log Analytics workspace, you can follow the below steps:
Option 1: Using Azure Portal
- Open the Azure Portal and navigate to your virtual machine.
- Under the "Monitoring" section, click on "Metrics" to open the metrics dashboard.
- In the "Metrics" blade, select the "Percentage CPU" metric and set the time range to the desired period.
- The graph will display the percentage of CPU usage over the selected period. The runtime of the virtual machine can be estimated by looking at the periods where the CPU usage is consistently high.
Option 2: Using Log Analytics Workspace
- Open the Azure Portal and navigate to your Log Analytics workspace.
- Click on "Logs" in the left-hand menu to open the Log Analytics query editor.
- Use the following query to get the overall runtime of the virtual machine:
Replace
<virtual machine name>
with the name of the virtual machine you want to check. - The query will return the overall runtime of the virtual machine in seconds. You can convert the output to minutes or hours as needed. Note: The "Heartbeat" table contains a record of every time a virtual machine sends a heartbeat to the Azure Monitor service. The "TimeGenerated" column indicates the time when the heartbeat was received. By subtracting the minimum and maximum values of the "TimeGenerated" column, we can determine the overall runtime of the virtual machine.
If this does answer your question, please feel free to mark it as the answer as a token of appreciation.