Azure / Azure/azure-powershell

Azure Alert - referenced object - (Properties.condition.datasource)

Open
#3,253 5 comments 0 reactions 1 assignee Claimed by @gucalder View on GitHub
act-observability-squad customer-reported Monitor - Alerts Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Cmdlet(s)
Set-AzureRmContext, get-AzureRmResource, get-azurermalertrule
### PowerShell Version
Instructions: to get PowerShell version, type `$PSVersionTable` and look for the value associated with `PSVersion`
5.0.10586.494
### Module Version
Microsoft.Azure.Commands.Insights 3.2.0
### OS Version
Instructions: to get OS version, type `$PSversionTable` and look for value associated with `BuildVersion`

### Description
When querying using a custom set of functions for "orphaned alerts" and running that against Classic resources it appears that the Data source for those alert types is not valid when calling Get-azurermresource.

For instance I have some alerts setup in one of my subscriptions that has a resource type of:
/providers/Microsoft.ClassicStorage/storageAccounts/bwpprod/services/blob

The monitor is watching this blob but if you call Get-azurermresource and look at the objects properties for Properties.condition.datasource it comes back as invalid. The value of the resource id in almost every other case points to a valid object in the portal that you can test with get-azurermresource from that value in properties.condition.datasource.

Also have noticed that some alert resources are there but the underlying link that the alert is watching, if you query for it with get-azurermresource it comes back with an invalid url.
Valid url:
subscriptions/xxxxx/resourceGroups/mygroup/providers/Microsoft.Sql/servers/webServer/databases/**W**ebDatabase
url that the alert object returns:
subscriptions/xxxxx/resourceGroups/mygroup/providers/Microsoft.Sql/servers/webServer/databases/**w**ebDatabase

In the case above the w is changed to uppercase and now get-azurermresource works just fine.

Could I be possibly be looking at the wrong property in the object? For instance we have some monitors thatare setup to watch a database and some of it's counters but when I look at the (properties.condition.datasource) the value for the alert that I'm looking at when used with get-azurermresource comes up invalid. Is it perhaps that the monitored alert source has been changed and the value for the alert wasn't updated with the new alert? Also have seen where alerts that are referencing a data source that has had one item in the name's case changed become invalid as well.

To see my scripting that I'm speaking of please see this gist https://gist.github.com/crshnbrn66/4bb4670d36f56e98efe35d2ad29ebd01
and these functions: (Get-PAzureOrphanedAlerts,Test-PAzureAlertSource,

### Debug Output
Debug doesn't apply in this condition just need clarity on where alerts are kept.

### Script/Steps for Reproduction
When querying using a custom set of functions for "orphaned alerts" and running that against Classic resources it appears that the Data source for those alert types is not valid when calling Get-azurermresource.

For instance I have some alerts setup in one of my subscriptions that has a resource type of:
/providers/Microsoft.ClassicStorage/storageAccounts/bwpprod/services/blob

The monitor is watching this blob but if you call Get-azurermresource and look at the objects properties for Properties.condition.datasource it comes back as invalid. The value of the resource id in almost every other case points to a valid object in the portal that you can test with get-azurermresource from that value in properties.condition.datasource.

Also have noticed that some alert resources are there but the underlying link that the alert is watching if you query for it with get-azurermresource it comes back with an invalid url.

Could I be possibly be looking at the wrong property in the object? For instance we have some monitors thatare setup to watch a database and some of it's counters but when I look at the (properties.condition.datasource) the value for the alert that I'm looking at when used with get-azurermresource comes up invalid. Is it perhaps that the monitored alert source has been changed and the value for the alert wasn't updated with the new alert? Also have seen where alerts that are referencing a data source that has had one item in the name's case changed become invalid as well.

to see my scripting that I'm speaking of please see this gist https://gist.github.com/crshnbrn66/4bb4670d36f56e98efe35d2ad29ebd01
and these functions: (Get-PAzureOrphanedAlerts,Test-PAzureAlertSource,

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.