How to set unit value in azurerm_monitor_metric_alert [Azure]

Hi, everyone

I would like to automate alert’s creation with Terraform on Azure. In my case, I want to create an alert about Used Capacity in Storage Account. For example, if capacity is greather than 40 Gb, it will send a email. However, I do not know how set the unit value (GiB).

An example on Azure:

An example with Terraform:

resource "azurerm_monitor_metric_alert" "terraform" {
  name                = "example-metricalert"
  resource_group_name =
  scopes              = []
  description         = "Action will be triggered when Transactions count is greater than 40."
  severity            = "3"
  window_size        = "PT1D"
  criteria {
    metric_namespace = "Microsoft.Storage/storageAccounts"
    metric_name      = "UsedCapacity"
    aggregation      = "Average"
    operator         = "GreaterThan"
    threshold        = "40"

Is it possible to set the unit value ?

Thanks in advance,


It looks like the unit is Bytes, so you’d have to convert / multiply it on your own.

1 Like

Hi, @tbugfinder

It works with default values, in this case with Bytes.