AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1168523
Accepted
Peter Kahn
Peter Kahn
Asked: 2024-12-05 03:28:56 +0800 CST2024-12-05 03:28:56 +0800 CST 2024-12-05 03:28:56 +0800 CST

是否可以使用 terraform azurerm 提供程序创建 azure 订阅配额警报?

  • 772

我看到azurerm提供程序有azurerm_monitor_metric_alert但似乎不支持azure 配额警报。各种 AI 认为我可以使用azurerm_monitor_metric_alert类似“/subscriptions/${data.azurerm_subscription.current.subscription_id}/providers/Microsoft.Compute/locations/${location}/providers/Microsoft.Quota/quotas/standardDPLDSv5Family”的范围

但事实似乎并非如此。似乎无法通过 Terraform 管理订阅配额警报。是这样吗?

azure
  • 1 1 个回答
  • 99 Views

1 个回答

  • Voted
  1. Best Answer
    Kirti Garg
    2025-01-16T19:10:05+08:002025-01-16T19:10:05+08:00

    这对我有用。

    尝试使用资源azurerm_monitor_scheduled_query_rules_alert_v2:

    resource "azurerm_monitor_scheduled_query_rules_alert_v2" "quota_alerts" {
      name                              = "quota-alerts"
      resource_group_name               = azurerm_resource_group.rg.name
      location                          = azurerm_resource_group.rg.location
      evaluation_frequency              = "PT5M"
      window_duration                   = "PT15M"
      scopes                            = [var.subscription-id]
      severity                          = 2
      description                       = "Quota Usage Alert Rule >=70%"
      display_name                      = "Quota Usage Alert Rule"
      enabled                           = true
      auto_mitigation_enabled           = true
      criteria {
        query                   = <<-QUERY
        arg("").QuotaResources
            | where subscriptionId =~ '${var.subscription-id}'
            | where type =~ 'microsoft.compute/locations/usages'
            | where isnotempty(properties)
            | mv-expand propertyJson = properties.value limit 400
            | extend
            usage = propertyJson.currentValue,
            quota = propertyJson.['limit'],
            quotaName = tostring(propertyJson.['name'].value)
            | extend usagePercent = toint(usage)*100 / toint(quota)| project-away properties| where quotaName in~ ('Standard NCASv3_T4 Family')
          QUERY
        time_aggregation_method = "Maximum"
        threshold               = 70
        operator                = "GreaterThanOrEqual"
    
        metric_measure_column = "usagePercent"
        dimension {
            name     = "location"
            operator = "Include"
            values   = ["*"]
        }
        dimension {
            name     = "quotaName"
            operator = "Include"
            values   = ["Standard NCASv3_T4 Family"]
        }
        dimension {
            name     = "type"
            operator = "Include"
            values   = ["microsoft.compute/locations/usages"]
        }
        failing_periods {
          minimum_failing_periods_to_trigger_alert = 1
          number_of_evaluation_periods             = 1
        }
      }
    
      action {
        action_groups = [azurerm_monitor_action_group.admin.id]
      }
    
      identity {
        type = "UserAssigned"
        identity_ids = [
          azurerm_user_assigned_identity.subscription-reader.id,
        ]
      }
    }
    
    • 0

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve