Server reboot on Linux VM - Alert rule

148 Views Asked by At

I'm looking to create an alert rule in Azure Monitor to detect server reboots on Linux VMs. I have one for server reboots on Windows VMs, but I cannot find how to detect this on Linux.

I tried searching on the signals available but could not find anything. It seems as the only possibility is a log query.

1

There are 1 best solutions below

8
Venkat V On

I'm looking to create an alert rule in Azure Monitor to detect server reboots on Linux VMs.

To create an alert when the Linux server restarts, you can follow the steps below.

  1. Go to Azure Monitor > Logs > execute the below KQL query
    AzureActivity
    | where ResourceProvider == "Microsoft.Compute" 
    | where OperationName == "Restart Virtual Machine" and ActivityStatus == "Succeeded"
    | extend VMName = extract("([^/]+$)", 1, tostring(ResourceId))
    | join kind=inner (
        Heartbeat
        | where OSType contains "Linux"
        | extend ComputerName = tostring(split(Computer, ".")[0])
        | project ComputerName, OSType
    ) on $left.VMName == $right.ComputerName
    | project TimeGenerated,OSType,VMName,OperationName,ActivityStatus,ResourceGroup,Caller

Response:

enter image description here

  1. Click on New Alert rule > create an alert rule

enter image description here

  1. Create an action group, or select an existing one if it has already been created.

enter image description here

  1. Configure the alert rule as per your requirement.

enter image description here

  1. You will receive an alert when the Linux server restarts.

enter image description here