Problem of setting up an alert on azure in the event of a freeze of a VM

Fakri SLIMANE 26 Reputation points
2022-09-05T13:56:50.707+00:00

Hello,

I would like to know how to set up an alert when my VM freezes, to be able to intervene very quickly.

237865-image.png

As you can see on the graph, when the VM freezes, there are small dotted lines where you can see that there is no value, probably a communication problem.

here, I would like to create an alert by sending an email when the VM freezes, but I tried and I can't do it because we can't leave the field without value, is there another way to achieve this? to have an alert?

237848-image.png

Cordially,
Fakri

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,802 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,129 questions
0 comments No comments
{count} votes

Accepted answer
  1. Maxim Sergeev 6,566 Reputation points Microsoft Employee
    2022-09-06T23:47:26.627+00:00

    For this type of alerts when you are checking missing data, I highly recommend taking aggregation granularity more than in query itself, for example 10 minutes in this case


2 additional answers

Sort by: Most helpful
  1. Maxim Sergeev 6,566 Reputation points Microsoft Employee
    2022-09-05T19:11:35.93+00:00

    Hi @Fakri SLIMANE ,

    Using VM Insights to capture missing heartbeats is an overkilling approach, if you don't need VM Insights at all.
    Install Azure Monitoring Agent to collect for example several events into Log Analytics Workspace (VM Insights is not required in this case), this will deploy Data Collection Rules with Azure Monitoring Agent. The fact is that you can't collect heartbeats only, so that's why you need to workaround this by collecting some minimum amount of data.

    https://learn.microsoft.com/en-us/azure/azure-monitor/agents/data-collection-rule-azure-monitor-agent?tabs=portal

    Then use the query to check missing heartbeats, create an alert rule based on that query

    Heartbeat   
    | summarize LastHeartbeat=max(TimeGenerated) by Computer   
    | where LastHeartbeat < ago(5min)  
    | project Computer, LastHeartbeat, SeverityName_s = "WARNING", AffectedCI_s = strcat(Computer)   
    

    When your VM is stuck or "frozen", I will receive a notification like that

    237929-image.png

    2 people found this answer helpful.

  2. kilian goëtz 146 Reputation points
    2022-09-05T16:32:58.967+00:00

    Hello,

    This tutorial could help you https://learn.microsoft.com/en-us/azure/azure-monitor/vm/tutorial-monitor-vm-alert solution is simple, you need VM insight and create a log query.

    "Once you enable monitoring with VM insights in Azure Monitor for the virtual machine, a heartbeat is sent to Azure Monitor every minute. You can create a log query alert rule that sends an alert if a heartbeat isn't detected"

    Kinds regards, Kilian GOËTZ.

    0 comments No comments