如何从 apim 应用洞察中获取后端 url
How to get back-end url from apim app insights
我有一个 apim 实例配置为记录应用程序洞察。
我 运行 以下 kusto 查询以提取有用的信息:
requests
| extend requestBody = customDimensions["Request-Body"]
| extend requestMethod = customDimensions["HTTP Method"]
| extend ApiName = customDimensions["API Name"]
| where ApiName == "client"
| project timestamp, ApiName, url, requestBody, requestMethod
| sort by timestamp desc
这个returns是apim实例的入站url的“url”。有谁知道如何更新它以拉回 apim 转发请求的后端 url?
如果您将后端应用程序的日志写入同一个 Application Insights 实例,您只需使用 APIM 请求的 operation_Id 将查询结果与“请求”table 连接起来和后端请求的operation_ParentId。
您还可以加入具有依赖性 table 的 APIM 请求。这也应该给你后端请求:
dependencies
| where timestamp > ago(1h)
| join (requests | where timestamp > ago(1h))
on operation_Id
之后您可以提取您感兴趣的字段。
编辑:
要仅使用 APIM 记录的数据获取后端 URL 字段而不将后端记录到 Application Insights,您可以使用依赖项 table 加入请求和依赖项的 'data' 字段,如下所示:
dependencies
| where timestamp > ago(1h)
| join (requests | where timestamp > ago(1h))
on operation_Id
| project backendUrl = data
我有一个 apim 实例配置为记录应用程序洞察。
我 运行 以下 kusto 查询以提取有用的信息:
requests
| extend requestBody = customDimensions["Request-Body"]
| extend requestMethod = customDimensions["HTTP Method"]
| extend ApiName = customDimensions["API Name"]
| where ApiName == "client"
| project timestamp, ApiName, url, requestBody, requestMethod
| sort by timestamp desc
这个returns是apim实例的入站url的“url”。有谁知道如何更新它以拉回 apim 转发请求的后端 url?
如果您将后端应用程序的日志写入同一个 Application Insights 实例,您只需使用 APIM 请求的 operation_Id 将查询结果与“请求”table 连接起来和后端请求的operation_ParentId。
您还可以加入具有依赖性 table 的 APIM 请求。这也应该给你后端请求:
dependencies
| where timestamp > ago(1h)
| join (requests | where timestamp > ago(1h))
on operation_Id
之后您可以提取您感兴趣的字段。
编辑: 要仅使用 APIM 记录的数据获取后端 URL 字段而不将后端记录到 Application Insights,您可以使用依赖项 table 加入请求和依赖项的 'data' 字段,如下所示:
dependencies
| where timestamp > ago(1h)
| join (requests | where timestamp > ago(1h))
on operation_Id
| project backendUrl = data