您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Application Insights 中的 AnalyticsAnalytics in Application Insights

Analytics 是 Application Insights 的强大搜索和查询工具。Analytics is the powerful search and query tool of Application Insights. Analytics 是一个 Web 工具,因此不需要安装。Analytics is a web tool so no setup is required. 如果已经为某个应用配置了 Application Insights,则可以通过从该应用的概述边栏选项卡打开 Analytics 来对应用数据进行分析。If you've already configured Application Insights for one of your apps then you can analyze your app's data by opening Analytics from your app's overview blade.

依次打开 portal.azure.com 和 Application Insights 资源,并单击“Analytics”。

还可以使用 Analytics 练习场,这是一个免费的演示环境,其中包含大量示例数据。You can also use the Analytics playground which is a free demo environment with a lot of sample data.

在 Analytics 中查询数据Query data in Analytics

典型查询以表名开头,后跟一系列由 | 分隔的运算符A typical query starts with a table name followed by a series of operators separated by |. 例如,接下来让我们查明我们的应用在过去 3 个小时内从不同的国家/地区收到了多少请求:For example, let's find out how many requests our app received from different countries, during the last 3 hours:

requests
| where timestamp > ago(3h)
| summarize count() by client_CountryOrRegion
| render piechart

使查询以表名 requests 开头,并根据需要添加以管道字符分隔的元素。We start with the table name requests and add piped elements as needed. 首先,我们定义一个时间筛选器,以便仅查看过去 3 个小时的记录。First we define a time filter to review only records from the last 3 hours. 然后,我们统计每个国家/地区的记录数(该数据位于 client_CountryOrRegion 列中)。We then count the number of records per country (that data is found in the column client_CountryOrRegion). 最后,我们将结果呈现在一个饼图中。Finally, we render the results in a pie chart.

查询结果

该语言具有许多相当不错的功能:The language has many attractive features:

  • 按任何字段(包括自定义属性和指标)筛选原始应用遥测。Filter your raw app telemetry by any fields, including your custom properties and metrics.
  • 加入多个表 – 将请求与页面视图、依赖项调用、 异常和日志跟踪关联起来。Join multiple tables – correlate requests with page views, dependency calls, exceptions and log traces.
  • 功能强大的统计聚合Powerful statistical aggregations.
  • 功能强大的即时可视化效果。Immediate and powerful visualizations.
  • 可以用来以编程方式运行查询的 REST API,例如通过 PowerShell。REST API that you can use to run queries programmatically, for example from PowerShell.

完整语言参考详细介绍了支持的每个命令并且会定期更新。The full language reference details every command supported, and updates regularly.

后续步骤Next steps