Skip to content

Commit dafbfe3

Browse files
Merge pull request #252319 from AbbyMSFT/api-dep
Add sample ARG queries for getting Azure monitor alerts
2 parents c14a044 + 49a925d commit dafbfe3

File tree

1 file changed

+41
-0
lines changed
  • articles/governance/resource-graph/samples

1 file changed

+41
-0
lines changed

articles/governance/resource-graph/samples/starter.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ This article uses the following starter queries:
3131
- [List all storage accounts with specific tag value](#list-specific-tag)
3232
- [List all tags and their values](#list-all-tag-values)
3333
- [Show unassociated network security groups](#unassociated-nsgs)
34+
- [List alerts by severity](#alerts-severity)
35+
- [List alerts by severity and resource type](#alerts-severity-state)
36+
- [List alerts by severity and resource type with a specific tag](#alerts-severity-service-type)
3437

3538
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free)
3639
before you begin.
@@ -654,6 +657,44 @@ Search-AzGraph -Query "Resources | where type =~ 'microsoft.network/networksecur
654657

655658
---
656659

660+
## <a name="alerts-severity"></a>List alerts ordered by severity
661+
662+
```kusto
663+
alertsmanagementresources
664+
| where type =~ 'microsoft.alertsmanagement/alerts' 
665+
| where todatetime(properties.essentials.startDateTime) >= ago(2h) and todatetime(properties.essentials.startDateTime) < now()
666+
| project Severity = tostring(properties.essentials.severity)
667+
| summarize AlertsCount = count() by Severity
668+
669+
```
670+
## <a name="alerts-severity-state"></a>List alerts ordered by severity and alert state
671+
672+
```kusto
673+
alertsmanagementresources
674+
| where type =~ 'microsoft.alertsmanagement/alerts' 
675+
| where todatetime(properties.essentials.startDateTime) >= ago(2h) and todatetime(properties.essentials.startDateTime) < now()
676+
| project Severity = tostring(properties.essentials.severity),
677+
AlertState= tostring(properties.essentials.alertState)
678+
| summarize AlertsCount = count() by Severity, AlertState
679+
```
680+
681+
## <a name="alerts-severity-service-type"></a>List alerts ordered by severity, monitor service, and target resource type
682+
683+
```kusto
684+
alertsmanagementresources
685+
| where type =~ 'microsoft.alertsmanagement/alerts' 
686+
| where todatetime(properties.essentials.startDateTime) >= ago(2h) and todatetime(properties.essentials.startDateTime) < now()
687+
| project Severity = tostring(properties.essentials.severity),
688+
MonitorCondition = tostring(properties.essentials.monitorCondition),
689+
ObjectState = tostring(properties.essentials.alertState),
690+
MonitorService = tostring(properties.essentials.monitorService),
691+
AlertRuleId = tostring(properties.essentials.alertRule),
692+
SignalType = tostring(properties.essentials.signalType),
693+
TargetResource = tostring(properties.essentials.targetResourceName),
694+
TargetResourceType = tostring(properties.essentials.targetResourceName), id 
695+
| summarize AlertsCount = count() by Severity, MonitorService , TargetResourceType
696+
```
697+
657698
## Next steps
658699

659700
- Learn more about the [query language](../concepts/query-language.md).

0 commit comments

Comments
 (0)