【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
问题描述
Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
这是在APIM门户上配置API,设置的Diagnostics Logs,当选择Application Insights时,就可以把对接口请求时候所携带的Header/Body等信息发送到Applciation Insights中进行存储并分析。
但是,在自建网关在K8S中,确无法发送日志到Applicaiton Insights,有什么办法呢?
问题解答
因为APIM Self-Host Gateway默认使用Application Insights的Endpoint ( https://dc.services.visualstudio.com/ ) 是Global Application Insights。而且在默认生产的YAML文件中,初始化并没有包含对Application Insights的设置项:
# NOTE: Before deploying to a production environment, please review the documentation -> https://aka.ms/self-hosted-gateway-production
---
apiVersion: v1
kind: ConfigMap
metadata:
name: testselfhost-env
labels:
app: testselfhost
data:
config.service.endpoint: "xxxxxxxxxx.configuration.azure-api.cn"
neighborhood.host: "testselfhost-instance-discovery"
runtime.deployment.artifact.source: "Azure Portal"
runtime.deployment.mechanism: "YAML"
runtime.deployment.orchestrator.type: "Kubernetes"
---
所以如果需要发送请求日志到中国区指定的Application Insights中,需要修改YAML文件,在configMap中添加 logs.applicationinsights.endpoint: "https://dc.applicationinsights.azure.cn/v2/track" , 效果如下图所示:
如上修改后,就能实现本地网关也发送数据到Appliation Insights中。
参考资料
如何将 Azure API 管理与 Azure Application Insights 集成:https://docs.azure.cn/zh-cn/api-management/api-management-howto-app-insights?tabs=rest#enable-application-insights-logging-for-your-api
使用 YAML 将自承载网关部署到 Kubernetes:https://docs.azure.cn/zh-cn/api-management/how-to-deploy-self-hosted-gateway-kubernetes
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2022-03-19 【Azure 环境】IntelliJ IDEA Community Edition 2021.2.3登陆Azure账号时,无法切换到中国区
2022-03-19 【Azure 应用服务】App Service 的.NET Version选择为.NET6,是否可以同时支持运行ASP.NET V4.8的应用呢?