You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/alerts/alerts-log-alert-query-samples.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,20 @@ A log alert rule monitors a resource by using a Log Analytics query to evaluate
14
14
15
15
This article provides examples of log alert rule queries that use Azure Data Explorer and Azure Resource Graph. For more information about creating a log alert rule, see [Create a log alert rule](./alerts-create-log-alert-rule.md).
16
16
17
-
## Query that checks virtual machine health
17
+
## Queries that check virtual machine health
18
18
19
-
This query finds virtual machines that are marked as critical and that had a heartbeat more than 24 hours ago, but that haven't had a heartbeat in the last 2 minutes.
19
+
This query finds virtual machines marked as critical that haven't had a heartbeat in the last 2 minutes.
20
+
21
+
```kusto
22
+
arg("").Resources
23
+
| where type == "microsoft.compute/virtualmachines"
24
+
| summarize LastCall = max(case(isnull(TimeGenerated), make_datetime(1970, 1, 1), TimeGenerated)) by name, id
This query finds virtual machines marked as critical that had a heartbeat more than 24 hours ago, but that haven't had a heartbeat in the last 2 minutes.
20
31
21
32
```kusto
22
33
{
@@ -38,15 +49,15 @@ This query finds virtual machines that are marked as critical and that had a hea
38
49
## Query that filters virtual machines that need to be monitored
39
50
40
51
```kusto
41
-
{
52
+
{
42
53
let RuleGroupTags = dynamic(['Linux']);
43
-
Perf | where ObjectName == 'Processor' and CounterName == '% Idle Time' and (InstanceName == '_Total' or InstanceName == 'total')
54
+
Perf | where ObjectName == 'Processor' and CounterName == '% Idle Time' and (InstanceName in ('_Total,'total'))
| where type =~ 'Microsoft.Compute/virtualMachines'
57
+
| where type =~ 'Microsoft.Compute/virtualMachines'
47
58
| project _ResourceId=tolower(id), tags) on _ResourceId
48
59
| project-away _ResourceId1
49
-
| where (isnull(tags.monitored) or tolower(tostring(tags.monitored)) != 'false') and (tostring(tags.monitorRuleGroup) in (RuleGroupTags) or isnull(tags.monitorRuleGroup) or tostring(tags.monitorRuleGroup) == '')
60
+
| where (tostring(tags.monitorRuleGroup) in (RuleGroupTags))
50
61
}
51
62
```
52
63
@@ -68,10 +79,10 @@ This query finds virtual machines that are marked as critical and that had a hea
0 commit comments