Skip to content

Commit 0882647

Browse files
Merge pull request #252206 from nolavime/patch-135
Update alerts-troubleshoot.md
2 parents de6d391 + a978712 commit 0882647

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

articles/azure-monitor/alerts/alerts-troubleshoot.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title: Troubleshooting Azure Monitor alerts and notifications
33
description: Common issues with Azure Monitor alerts and possible solutions.
44
ms.topic: reference
5-
ms.date: 2/23/2022
6-
ms.reviewer: ofmanor
5+
ms.date: 9/20/2023
6+
ms.reviewer: nolavime
77
---
88
# Troubleshooting problems in Azure Monitor alerts
99

@@ -247,6 +247,57 @@ If you received an error while trying to create, update or delete an [alert proc
247247

248248
Check the [alert processing rule documentation](../alerts/alerts-action-rules.md), or the [alert processing rule PowerShell Set-AzActionRule](/powershell/module/az.alertsmanagement/set-azalertprocessingrule) command.
249249

250+
## How to Migrate the Get alert summary API to ARG query
251+
252+
Get alert summary API return the summary of alerts using API, today once we opened the option to use ARG query everywhere (including alerts) you can use ARG query directly and by that to have an option to be more flexible.
253+
If you are using “GetAlertSummary” API, we recommend using ARG query API and list out the benefits
254+
* Ability to add new fields to the query that returns the alert summary.
255+
* Ability to be more flexible in the query that returns the alert summary.
256+
This is an example of how today we use “GetAlertSummary” API:
257+
258+
GET https://management.azure.com/subscriptions/{subId}/providers/Microsoft.AlertsManagement/alertsSummary?groupby=severity,alertState&api-version=2019-03-01
259+
Response: AlertSummary_Sev_Alertstate
260+
261+
Instead of “GetAlertSummary” API you can create a query via ARG, examples for 2 uses of ARG query that can be used instead of “GetAlertSummary” API using different parameters. You can use this as a baseline for your query and build it exactly according to your needs.
262+
* Query to ARG by Severity, AlertState:
263+
Post  https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2020-04-01-preview
264+
{
265+
query: "alertsmanagementresources
266+
| where type =~ 'microsoft.alertsmanagement/alerts' 
267+
| where todatetime(properties.essentials.startDateTime) >= ago(2h) and todatetime(properties.essentials.startDateTime) < now()
268+
| project Severity = tostring(properties.essentials.severity),
269+
AlertState= tostring(properties.essentials.alertState)
270+
| summarize AlertsCount = count() by Severity, AlertState"
271+
}
272+
* Query to ARG by Severity:
273+
Post  https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2020-04-01-preview
274+
{
275+
query: "alertsmanagementresources
276+
| where type =~ 'microsoft.alertsmanagement/alerts' 
277+
| where todatetime(properties.essentials.startDateTime) >= ago(2h) and todatetime(properties.essentials.startDateTime) < now()
278+
| project Severity = tostring(properties.essentials.severity)
279+
| summarize AlertsCount = count() by Severity"
280+
}
281+
* Query to ARG by Severity, monitorService, TargetResourceType
282+
Post  https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2020-04-01-preview
283+
{
284+
query: "alertsmanagementresources
285+
| where type =~ 'microsoft.alertsmanagement/alerts' 
286+
| where todatetime(properties.essentials.startDateTime) >= ago(2h) and todatetime(properties.essentials.startDateTime) < now()
287+
| project Severity = tostring(properties.essentials.severity),
288+
MonitorCondition = tostring(properties.essentials.monitorCondition),
289+
ObjectState = tostring(properties.essentials.alertState),
290+
MonitorService = tostring(properties.essentials.monitorService),
291+
AlertRuleId = tostring(properties.essentials.alertRule),
292+
SignalType = tostring(properties.essentials.signalType),
293+
TargetResource = tostring(properties.essentials.targetResourceName),
294+
TargetResourceType = tostring(properties.essentials.targetResourceName),
295+
id 
296+
| summarize AlertsCount = count() by Severity, MonitorService , TargetResourceType"
297+
}
298+
299+
300+
250301

251302
## Next steps
252303
- If using a log alert, also see [Troubleshooting Log Alerts](./alerts-troubleshoot-log.md).

0 commit comments

Comments
 (0)