如何为 Azure 应用程序网关不健康后端创建警报?

问题描述 投票:0回答:1

我尝试过使用以下选项

  1. Azure 监视器警报
  2. Powershell 脚本

我正在尝试测试应用程序网关。

我尝试使用 Azure Monitor 和信号 - 应用程序网关的不健康主机计数创建警报。当我尝试使用此条件创建警报时,有一个选项可以选择维度。一旦我选择警报就会触发,但它只显示后端池名称和后端设置名称,但不显示错误是什么?

我还尝试使用 powershell 脚本和以下命令

Get-AzApplicationGatewayBackendHealth -Name "xxx" -ResourceGroupName "xxx" | Select -ExpandProperty BackendAddressPools | Select -ExpandProperty BackendHttpSettingsCollection | Select -ExpandProperty servers | Select-Object -Property "Address", "Health" | Where-Object -Property Health -eq "Unhealthy

它为我提供了不健康的后端服务器的列表,但它没有向我显示 healthprobelog(错误类型)。

但是当我尝试以下 Azure CLI 命令时,我收到 healthprobelog“az network application-gateway show-backend-health --resource-group xxx --name xxx”

有人可以提供为相关应用程序团队创建警报邮件的解决方案吗?

powershell azure-powershell azure-application-gateway
1个回答
0
投票

您可以利用日志警报来检测应用程序网关的不健康主机计数,如下所示。

AzureMetrics
| where ResourceProvider == "MICROSOFT.NETWORK"
| where ResourceId contains "APPLICATIONGATEWAYS"
| where MetricName == "UnhealthyHostCount" // This metric indicates unhealthy hosts
| summarize UnhealthyHosts = max(Maximum) by bin(TimeGenerated, 5m), ResourceId
| project TimeGenerated, ResourceId, UnhealthyHosts
| order by TimeGenerated desc

在这里,您可以找到不健康的主机并直接创建新警报,如下所示。

enter image description here

您可以在信号名称创建操作和警报规则详细信息中使用自定义日志搜索

enter image description here

enter image description here

一旦创建警报,任何不健康的问题都会在您所需的时间内触发警报,如下所示:

enter image description here

参考

应用程序网关的 Azure Monitor 指标 |微软学习

© www.soinside.com 2019 - 2024. All rights reserved.