您好,我正在努力通过 Azure API 管理获取请求,但是我正在获取所有现有的 api。我只想过滤我需要的 api
这是我所做的:
requests
|summarize totalCount=sum(itemCount) by bin(timestamp,15m),toString(customDimensions.["API Name"])
where (toString(customDimensions.["API Name"]) == "api1" && "api2"
|render timechart
当我测试它时,它告诉我状态:有些东西坏了,我怎样才能从所有人中过滤出我需要的 api
将查询更改为
requests
| extend apiName = tostring(customDimensions.["API Name"])
| summarize totalCount=sum(itemCount) by bin(timestamp,15m),apiName
| where apiName in ("api1", "api2")
| render timechart
要深入了解请求,您需要了解应用程序。您可以将 ApplicationInsights 链接到 APIM 实例以进行监控。
在 Azure 中创建 Application Insights
并复制生成的 Instrumentation key
。
浏览到 APIM 资源,滚动到 Monitoring
部分以选择 Application Insights
。使用上面复制的 Instrumentation key
。
默认情况下,所有传入和传出的监控未开启。要启用它,请在 APIM 中滚动到 API 部分以选择 APIs
。在顶部选择设置并启用 Application Insights。
现在一切准备就绪,可以监控您的 API。
在 azure 文档中找到了解决方案。 该语言称为kusto 这是文档的链接:Azure Kusto Query language
requests
| extend apiName = tostring(customDimensions.["API Name"])
| summarize totalCount=sum(itemCount) by bin(timestamp,15m),apiName
| where apiName in ("api1", "api2")
| render timechart