问题描述
在APIM Gateway 日志中, 对于发送到APIM Host的请求,只记录了一些常规的URL, Status, Time, IP等信息。关于请求Header, Body中的信息,因为隐私保护的原因,默认没有记录。
[Info] 2023-11-16T06:19:28.482 [GatewayLogs],
isRequestSuccess: True,
totalTime: 2196,
category: GatewayLogs,
callerIpAddress: xxx.xxx.xxx.xxx,
timeGenerated: 2023-11-16T06:19:28.482,
region: ChinaNorth3,
correlationId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
method: GET,
url: https://xxx.xxx.xxx.xxx/echo/resource?param1=sample,
backendResponseCode: 200,
responseCode: 200,
responseSize: 674,
cache: none,
backendTime: 2004,
apiId: echo-api,
operationId: retrieve-resource,
apimSubscriptionId: master,
clientTime: 3,
clientProtocol: HTTP/1.1,
backendProtocol: HTTP/1.1,
apiRevision: 1,
clientTlsVersion: 1.2,
backendMethod: GET,
backendUrl: http://echoapi.cloudapp.net/api/resource?param1=sample,
correlationId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
那么,是否有办法增加日志内容,让Gateways日志中记录请求的Header,Body信息呢?
问题解答
当然可以,在APIM中,在配置APIs时,可以在Settings(设置)页面启用 Diagnostics Logs(诊断日志)来实现需求:
第一步:在APIs Diagnostics Logs中启用日志(Local 中的设置就是为自建网关(Self-hosted Gateway)适用)
第二步:启用后,进入 Self-hosted Gateway(如AKS POD), 就可以查看到上图配置的Name信息
参考资料
诊断日志设置参考: https://docs.azure.cn/zh-cn/api-management/diagnostic-logs-reference
将自承载网关部署到 Kubernetes : https://docs.azure.cn/zh-cn/api-management/how-to-deploy-self-hosted-gateway-kubernetes
【END】
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
标签:网关,xxxx,cn,xxx,Header,api,APIM,日志 From: https://blog.51cto.com/u_13773780/8377632