New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
set monitor alert for all services in an azure resource group (vm's, storage accounts..) #4337
Comments
I tried following code and failed as well: resource "azurerm_monitor_metric_alert" "main" { severity = 3 criteria { action { Error: Error: Error creating or updating metric alert "xxxxx-vm-alert-cpu" (resource group "xxxxx-resources"): insights.MetricAlertsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Alert scope is invalid." But I can do the same thing from Portal !!! |
This comment has been minimized.
This comment has been minimized.
It should also be possible to set the scope to subscription level as well. This is possible via ARM and the Portal and is a valid configuration for example, to set the CPU alert for All VMs in the subscription, it will then apply to any newly created VM resources. The below should be a valid configuration; resource "azurerm_monitor_metric_alert" "vm-cpu" { criteria { } action { Error: Error creating or updating metric alert "vm-cpu-metric-alert" (resource group "rg-plat-uks-dev"): insights.MetricAlertsClient#CreateOrUpdate: Failure responding to request: |
Found a list of supported newer metrics
|
If I try to set the metric " Unfortunately, I always get the following error: But if I use the RG as ...everything is working fine. I need to make sure, if a new VM will be added to the subscription, it must be monitored as well. How can I make sure, that an assignment to a subscription works, like the following screenshot illustrates? Any recommendations? Thx! |
Is there a way to disable alert for a certain unhandled exception in AppInsights: System.Threading.Tasks.TaskCanceledException I.e. if exception is one of those we don't need to get alerted? |
For anyone wondering if they can get around this by deploying an ARM template with Terraform, the resource group variable in the ARM template for resource group level alerting only accepts arrays, which cannot be passed in by Terraform as pointed out in this issue. Hopefully if anyone is thinking of going down that road I can save them some time and headaches. |
Does anyone have a solution or workaround about it?? I have the same problem, I can't create a rule and apply it to all virtual machines within the resource group. Thanks. |
I tested the same issue, I can't create a rule and apply it to all virtual machines within the resource group. |
Same issue, any workaround? |
Same issue. |
Hi @jliang888 , unfortunately I still do not have a solution to use the subscription level as scope. |
Hi, according to the doc, the scopes is supposed to a list, so I tried to put a multiple resource id in the list, like what you did here: |
Community Note
Description
Currently when using Terraform to create a azurerm_monitor_metric_alert or azurerm_monitor_metric_alertrule it only supports creating alerts for individual resources and not all resources in a resource_group - i.e. I have to create an individual alert rule for every individual virtual machine within a resource_group, I can't create a rule and apply it to all virtual machines within the resource group.
New or Affected Resource(s)
azurerm_metric_alertrule
Potential Terraform Configuration
References
Apparently this is supported in ARM templates using the
odata.type
metric and configuring it toSingleResourceMultipleMetricCriteria
.Documents for the ARM templates can be found here - Azure - static-threshold-alert-on-all-virtual-machines-in-one-or-more-resource-groups. It should also be noted that in this linked ARM template, under the key
"targetResourceType"
there is a comment in"metadata"
a couple lines down that declares"Resource type of target resources to be monitored. Currently only supported resource type is Microsoft.Compute/virtualMachines"
. This obviously leads me to assume that currently Azure doesn't even support this functionality in ARM templates outside of monitoring all virtual machines within a resource group which may render this request superfluous for the time being.The text was updated successfully, but these errors were encountered: