问题描述
我已为APIM启用了诊断日志,该日志已发送到日志分析.场景服务器的所有传入请求都具有 RequestTracking_Id
标头.所有后端服务在日志中使用请求中的 RequestTracking_Id
标头来跟踪请求.但是从APIM日志中,我无法提取此标头进行查询.
I've enabled diagnostic logs for APIM which are being sent to log-analytics.ScenarioAll incoming requests to server have RequestTracking_Id
header.All backend services use RequestTracking_Id
header from the request in logs to track the request.But from in APIM logs, I'm not able to pull this header to query upon.
是否有可能在APIM诊断日志中包含传入请求的标头信息?
Is there any way it is possible to have header information of incoming requests in APIM diagnostic logs?
查询:
AzureDiagnostics
| where Type contains "Azure" and Resource contains "APIM-DEV" and backendUrl_s contains "/relativePath" and DurationMs > 2000
可用于查询的列是:
推荐答案
如果要根据您的应用程序指定特定的日志.您可以在端点级别/api级别/产品级别的apim策略中使用< log-to-eventhub/>
.
If you want specific logs according to your application. You can use <log-to-eventhub/>
in apim policy in the endpoint level / api level / product level.
请查看以下链接,以了解有关此政策的更多信息.https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/api-management/api-management-log-to-eventhub-sample.md
Please see below link to know moer about this policy.https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/api-management/api-management-log-to-eventhub-sample.md
在策略中,您将从 context
对象获得所有请求和响应对象.请查看链接以了解有关上下文变量的更多信息. https://docs.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables
In policy, you will get all the request and response objects from context
object.Please see the link to know more about Context variables.https://docs.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables
对于标题,您可以查找字典对象 context.Request.Header
For headers, you can lookup the dictionary object context.Request.Header
这篇关于查询Azure APIM诊断日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!