azure - 获取 Azure 警报详细信息页面的 URL
问题描述
我正在使用逻辑应用程序创建一个 webhook(用于日志搜索警报),然后将警报有效负载推送到 slack。我正在尝试将 url 与警报有效负载数据(松弛)一起发送到实际警报详细信息页面,而不使用内置字段linkToSearchResults,因为该 url 很大,因为我的查询很长。我本质上想要一个友好的 url,类似于 azure 用于在 Azure Monitor 中查看警报的电子邮件模板中提供的 url 。我无法找到将这个链接放在一起的方法,我知道我可以在我的 webhook 的警报上使用自定义 json 有效负载,但是我将如何生成这个友好的 url?
解决方案
我相信问题更多是关于如何获得实际警报的链接,就像在这样的电子邮件中显示的那样。
而 linkToSearchResults 进入我们可以执行搜索查询的页面。
更多地查看警报的链接,它似乎被格式化为
https://ms.portal.azure.com/#blade/Microsoft_Azure_Monitoring/AlertDetailsTemplateBlade/alertId/%2fsubscriptions%2f<subscription_id>%2fproviders%2fMicrosoft.AlertsManagement%2falerts%2f<alert_id>/invokedFrom/emailcommonschema
现在,如果我们查看启用公共模式时作为警报的一部分收到的 json,它具有这些信息。
{
"essentials": {
"alertId": "/subscriptions/<subscription ID>/providers/Microsoft.AlertsManagement/alerts/b9569717-bc32-442f-add5-83a997729330",
"alertRule": "Contoso IT Metric Alert",
"severity": "Sev3",
"signalType": "Metric",
"monitorCondition": "Fired",
"monitoringService": "Platform",
"alertTargetIDs": [
"/subscriptions/<subscription ID>/resourceGroups/aimon-rg/providers/Microsoft.Insights/components/ai-orion-int-fe"
],
"originAlertId": "74ff8faa0c79db6084969cf7c72b0710e51aec70b4f332c719ab5307227a984f",
"firedDateTime": "2019-03-26T05:25:50.4994863Z",
"description": "Test Metric alert",
"essentialsVersion": "1.0",
"alertContextVersion": "1.0"
}
}
来自msdoc的参考。
让我们看看,这个模式有essentials.alertId,它看起来很熟悉上面 url 中使用的内容(但以 url 编码形式)。
所以最终生成友好 url 来提醒的代码变成了这样
string.Format("https://ms.portal.azure.com/#blade/Microsoft_Azure_Monitoring/AlertDetailsTemplateBlade/alertId/{0}",
HttpUtility.UrlEncode(alertEssentials.AlertId)),
希望这可以帮助!
推荐阅读
- javascript - 在uiSchema中为复杂对象形成多个组
- image-processing - 问题 SamplingRateCalculatorList (00000283DDC3C0E0):所有类都是空的!OTB + QGis
- weblogic12c - Weblogic 12c - 托管服务器由于无法访问管理服务器而失败
- sql - 为具有多个重复项的多个列创建组
- html - 我需要在图像旁边放置文本,并将它们从上到下堆叠
- java - 如何将多个sql脚本执行到具有相同版本的flyway中
- c++ - 将字节数组传递给 C++ 中的 WMI 提供程序类
- excel - 如果下面行中的单元格包含日期,如何插入公式?
- html - 如何在 HTML5 中为 HTML 输入提及特定长度(5 或 10)
- excel - 工作簿子例程不能从 VB6 中直接按名称调用