如何使用Azure Data Studio查询Application Insight数据并连接其实例
连接Azure Data Studio到Application Insights实例
首先得确保Azure Data Studio装了Azure Monitor扩展——这是连接Application Insights的必要前提。
步骤1:安装Azure Monitor扩展
打开Azure Data Studio,点左侧边栏的「扩展」图标(或按快捷键Ctrl+Shift+X),搜索「Azure Monitor」,找到后点击「安装」,装完重启Azure Data Studio就能生效。
步骤2:添加Application Insights连接
- 点左侧边栏的「连接」图标(或按
Ctrl+Shift+G),点击「新建连接」。 - 在弹出的连接类型列表里,选「Azure Monitor」分类下的「Application Insights」。
- 填写连接信息:
- 账户/订阅:选你的Azure账户,以及包含目标Application Insights实例的订阅。
- 资源组:选中实例所在的资源组。
- Application Insights实例:从下拉列表里挑你要连接的目标实例。
- 点击「连接」,等验证完成后,就能在连接列表里看到这个实例了。
使用Azure Data Studio查询Application Insights数据
连接成功后,有两种常用方式查询数据:
方式1:用内置查询模板
- 在连接列表里右键点击你的Application Insights实例,选「新建查询」。
- Azure Data Studio会自动加载针对Application Insights的预设查询模板,覆盖请求日志、异常追踪、性能指标等常用场景,你可以直接改模板里的参数来使用。
方式2:手动编写Kusto查询语言(KQL)
Application Insights的数据查询用的是Kusto语言,你可以直接在查询编辑器里写KQL语句,比如:
- 查询最近24小时的请求日志:
requests | where timestamp > ago(24h) | project timestamp, name, url, duration, resultCode | order by timestamp desc
- 查询最近12小时的异常记录:
exceptions | where timestamp > ago(12h) | project timestamp, type, message, details | order by timestamp desc
写完后点工具栏的「运行」按钮(或按F5),就能看到查询结果。
内容的提问来源于stack exchange,提问作者Allan Xu
相关产品推荐
相关产品推荐

