question

MDSaif-8182 avatar image
0 Votes"
MDSaif-8182 asked stan commented

Getting blank output in Alerts-Get All API

I am using the below mentioned API to get the cost alerts, but I am getting a blank output.

"GET https://management.azure.com/{scope}/providers/Microsoft.AlertsManagement/alerts?api-version=2019-03-01"

The scope that I am using is at the resource group level (subscriptions/" + subscription_id + "/resourceGroups/" + resource_group_name)

There is a cost alert in Cost Management+Billing -> Cost Alerts, but the API is still giving me a blank output like this :

{
"value": []
}

azure-monitor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

stan avatar image
0 Votes"
stan answered stan commented

Hi,
The above API is not for cost management alerts. The API for budget alerts is this.

The above API is for Azure Monitor alerts. Keep in mind that the API is for alert instances not for alert rules, so you need actual alert instances.

Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Under Monitor -> Alerts(In Azure Portal), I can see there are 8 total alerts, but I am not getting any of them using the below mentioned API.

"GET https://management.azure.com/{scope}/providers/Microsoft.AlertsManagement/alerts?api-version=2019-03-01"

Can you please help me with this?

0 Votes 0 ·

Check you scope. Probably the alerts are under scope which you are not querying. Overall it is best to use Azure Resource Graph to get alerts data as it will be faster and more efficient. Portal also uses the Azure Resource graph rather the API.


0 Votes 0 ·

I am calling this API - POST https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2019-04-01, to get the alerts data, but I am getting 0 as output.

But in the Azure Resource Graph Explorer(in portal) I am able to get the count properly.

Please help me with this issue.

Thanks

0 Votes 0 ·
Show more comments