Azure alerts terraform

gnuruwi 5 Reputation points
2023-10-25T13:09:43.8933333+00:00

Hi, I'm working on set of alerts in azure to cover my Linux, Windows, SQLServers CPU, memory,disk, state etc. using terraform.

I have multiple account and in each i have multiple resource groups.

What should be the approcach to loop through all accounts, all resource groups.

What limitations i possibly could encounter.

BR,

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,921 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AnuragSingh-MSFT 20,986 Reputation points
    2023-10-30T07:58:15.6066667+00:00

    gnuruwi, The "Metrics based alert rules" can be used to target all the resources in a single subscription, even though when residing in different resource groups in this subscription. Using azurerm_monitor_metric_alert provider, you may use the combination of the following arguments to achieve this:

    Scope - Set this to Subscription resource id (for example - /subscriptions/<SUBSCRIPTION_ID>)

    It seems that currently you have used Scope to target a single resource group, therefore the rule only gets applied to VM in that resource group. If the target is done at Subscription level, then all the resource groups inside this subscription and consequently all the VMs in these resource groups becomes the target.

    Furthermore, criteria should be used to refine the target. For example, if the metric based alert rule is for VM, the criteria should specify the criteria.target_resource_type as Microsoft.Compute/virtualMachines

    This will edit this metric rule to target all VMs in this specific scope (which the subscription in this case).


    Regarding the limitations, the limitations as available for Subscription Management and Monitoring resources also applies when the resources are deployed through terraform:

    Hope this helps. Please let me know if you have any questions.

    1 person found this answer helpful.

  2. gnuruwi 5 Reputation points
    2024-05-07T07:39:53.84+00:00

    Hi Anurag, Coming back to topic and i found this link all most all the Metric alerts and related properties.

    https://azure.github.io/azure-monitor-baseline-alerts/welcome/

    And further wanted ask question about resource types which do not support "Multi-resource alerts" as of now.

    For example, i need to configure set of alerts for Storge account and Load Balancer and both do not support for multi-resource alerts. I have requested these by voting in the portal. Any idea about this feature availability?

    At the moment, only way to get this done is by specifying under laying resource group of storage account or the load balancer. Do you see better approach for this ?

    Thanks in advance.

    @Ruwinda Fernando

    0 comments No comments