Azure Monitor / Log Analytics指标警报查询,需要重定向端到端事务详细信息窗口

jgwigjjp  于 2023-08-07  发布在  其他
关注(0)|答案(2)|浏览(85)

我创建了一个电子邮件通知,以便在每次异常触发电子邮件时向接收者发送一些详细信息。像这样


的数据
以及以下细节



我们需要参加“端到端交易”选项,以每个电子邮件,所以当收件人点击链接,我重定向端到端交易窗口。如何添加此。


zqry0prt

zqry0prt1#

这是不可能的。接收方应手动导航到Azure门户->“端到端交易”,或者您手动单击“端到端交易”中的“复制链接”并将链接直接发送给客户。
顺便说一下,您可以在Azure Monitor-Application Insights站点上建议将其作为一个功能,如suggestion
希望对你有帮助。

2lpgd968

2lpgd9682#

如果你不介意使用我为此目的而做的这个黑客函数,这是可能的:

let encode_operationid_hardlink_to_transaction_srch = (ResourceId: string, StartTime: datetime, EndTime: datetime, OperationId: string) { 
let UrlEncodedResource = url_encode(url_encode(ResourceId));
let UrlEncodedStartTime = url_encode(tostring(StartTime));
let UrlEncodedEndTime = url_encode(tostring(EndTime));
let TimeDiff = datetime_diff('millisecond', EndTime, StartTime);
let Url = ```
https://portal.azure.com/#blade/AppInsightsExtension/BladeRedirect/BladeName/searchV1/ResourceId/
%UrlEncodedResource%
/BladeInputs/%7B%22tables%22%3A%5B%22availabilityResults%22%2C%22requests%22%2C%22exceptions%22%2C%22pageViews%22%2C%22traces%22%2C%22customEvents%22%2C%22dependencies%22%5D%2C%22timeContextWhereClause%22%3A%22%7C%20where%20timestamp%20%3E%20datetime(%5C%22
%UrlEncodedStartTime%
%5C%22)%20and%20timestamp%20%3C%20datetime(%5C%22
%UrlEncodedEndTime%
%5C%22)%22%2C%22filterWhereClause%22%3A%22%7C%20where%20*%20has%20%5C%22
%OperationId%
%5C%22%7C%20order%20by%20timestamp%20desc%22%2C%22originalParams%22%3A%7B%22eventTypes%22%3A%5B%7B%22value%22%3A%22availabilityResult%22%2C%22tableName%22%3A%22availabilityResults%22%2C%22label%22%3A%22Availability%22%7D%2C%7B%22value%22%3A%22request%22%2C%22tableName%22%3A%22requests%22%2C%22label%22%3A%22Request%22%7D%2C%7B%22value%22%3A%22exception%22%2C%22tableName%22%3A%22exceptions%22%2C%22label%22%3A%22Exception%22%7D%2C%7B%22value%22%3A%22pageView%22%2C%22tableName%22%3A%22pageViews%22%2C%22label%22%3A%22Page%20View%22%7D%2C%7B%22value%22%3A%22trace%22%2C%22tableName%22%3A%22traces%22%2C%22label%22%3A%22Trace%22%7D%2C%7B%22value%22%3A%22customEvent%22%2C%22tableName%22%3A%22customEvents%22%2C%22label%22%3A%22Custom%20Event%22%7D%2C%7B%22value%22%3A%22dependency%22%2C%22tableName%22%3A%22dependencies%22%2C%22label%22%3A%22Dependency%22%7D%5D%2C%22timeContext%22%3A%7B%22durationMs%22%3A
%TimeDiff%
%2C%22endTime%22%3A%22
%UrlEncodedEndTime%
%22%7D%2C%22filter%22%3A%5B%5D%2C%22searchPhrase%22%3A%7B%22originalPhrase%22%3A%22
%OperationId%
%22%2C%22_tokens%22%3A%5B%7B%22conjunction%22%3A%22and%22%2C%22value%22%3A%22
%OperationId%
%22%2C%22isNot%22%3Afalse%2C%22kql%22%3A%22%20*%20has%20%5C%22
%OperationId%
%5C%22%22%7D%5D%7D%2C%22sort%22%3A%22desc%22%7D%7D
```;

字符串
资源id可以从标准列中的_ResourceId中获取(但我认为只有在洞察是基于工作空间的情况下)
上面的函数可以这样使用:transaction_search_link=encode_operationid_hardlink_to_transaction_srch(_ResourceId,now()-5m,now()+2h,operation_Id)
该链接将直接将您带到相应App Insights的交易搜索刀片,并完美填写日期,以便您查看交易。
现在,为了将此信息添加到警报电子邮件正文中,我使用了另一种技巧:
在日志警报中,您可以定义维度。这些通常用于对结果进行分组,但您也可以使用它们将其他信息添加到电子邮件中。请确保将transaction_search_link字段添加到维中,并且不要选择任何值。Dimensions in Alert Query(如果您找不到任何维度可供选择,请重新创建警报规则,以便将其更新为最新版本)
您将收到的电子邮件看起来像这样:Alert Email excerpt
请记住,这是相当黑客,如果微软决定改变任何有关搜索刀片网址或电子邮件警报,它将打破。我不想创建一个完全独立的服务只是为了解析警报电子邮件,所以这似乎是一个很好的解决方案。

相关问题