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

在 Application Insights 中浏览指标Exploring Metrics in Application Insights

Application Insights 中的指标是从应用程序遥测功能发送的度量值和事件计数。Metrics in Application Insights are measured values and counts of events that are sent in telemetry from your application. 它们可帮助检测性能问题,观察应用程序的用法趋势。They help you detect performance issues and watch trends in how your application is being used. 标准指标的范围很广泛,也可以创建自己的自定义指标和事件。There's a wide range of standard metrics, and you can also create your own custom metrics and events.

指标和事件计数显示在聚合值图表(例如总和、平均值或计数)中。Metrics and event counts are displayed in charts of aggregated values such as sums, averages, or counts.

下面是示例图表集:Here's a sample set of charts:

可在 Application Insights 门户中的任何位置找到指标图表。You find metrics charts everywhere in the Application Insights portal. 在大多数情况下,它们可以进行自定义,可以向边栏选项卡添加更多图表。In most cases, they can be customized, and you can add more charts to the blade. 在“概览”边栏选项卡中,单击“浏览更详细的图表”(它们具有诸如“服务器”这类的标题),或单击“指标资源管理器”以打开新边栏选项卡,可以在其中创建自定义图表。From the Overview blade, click through to more detailed charts (which have titles such as "Servers"), or click Metrics Explorer to open a new blade where you can create custom charts.

时间范围Time range

可以在任何边栏选项卡上更改图表或网格覆盖的时间范围。You can change the Time range covered by the charts or grids on any blade.

在 Azure 门户中打开应用程序的概览边栏选项卡

如果某些数据未按预期出现,请单击“刷新”。If you're expecting some data that hasn't appeared yet, click Refresh. 图表将定期自动刷新,但时间范围越大,刷新间隔时间越长。Charts refresh themselves at intervals, but the intervals are longer for larger time ranges. 数据通过分析管道显示在图表上可能需要一些时间。It can take a while for data to come through the analysis pipeline onto a chart.

若要放大图表的某个部分,请在该部分上拖动鼠标:To zoom into part of a chart, drag over it:

在图表的某个部分上拖动鼠标。

单击“撤消缩放”按钮可将该部分还原。Click the Undo Zoom button to restore it.

粒度和点值Granularity and point values

将鼠标悬停在图表上可显示该点的指标值。Hover your mouse over the chart to display the values of the metrics at that point.

将鼠标悬停在图表上

特定点的指标值基于前一个采样间隔聚合。The value of the metric at a particular point is aggregated over the preceding sampling interval.

采样间隔或“粒度”显示在边栏选项卡的顶部。The sampling interval or "granularity" is shown at the top of the blade.

边栏选项卡的标题。

可在“时间范围”边栏选项卡中调整粒度:You can adjust the granularity in the Time range blade:

边栏选项卡的标题。

可提供的粒度取决于选择的时间范围。The granularities available depend on the time range you select. 显式粒度可替代时间范围内的“自动”粒度。The explicit granularities are alternatives to the "automatic" granularity for the time range.

编辑图表和网格Editing charts and grids

在边栏选项卡中添加新图表:To add a new chart to the blade:

在指标资源管理器中,选择“添加图表”

在现有图表或新图表中选择“编辑”来编辑其显示内容:Select Edit on an existing or new chart to edit what it shows:

选择一个或多个指标

可以在图表上显示多个指标,但是,可以一起显示的组合有一些限制。You can display more than one metric on a chart, though there are restrictions about the combinations that can be displayed together. 只要选择一个指标,就会禁用其他一些指标。As soon as you choose one metric, some of the others are disabled.

如果在应用中编写了自定义指标(对 TrackMetric 和 TrackEvent 的调用),此处会列出这些指标。If you coded custom metrics into your app (calls to TrackMetric and TrackEvent) they will be listed here.

将数据分段Segment your data

可以根据属性拆分指标 - 例如,比较使用不同操作系统的客户端上的页面视图。You can split a metric by property - for example, to compare page views on clients with different operating systems.

选择图表或网格,将分组切换为打开,然后选择用作分组依据的属性:Select a chart or grid, switch on grouping and pick a property to group by:

选择“打开分组”,并在“分组依据”中选择属性

备注

使用分组时,“分区图”和“条形图”类型提供堆积视图。When you use grouping, the Area and Bar chart types provide a stacked display. 这适用于“聚合”方法为“求和”的情况。This is suitable where the Aggregation method is Sum. 但如果聚合类型为“平均”,请选择“线条图”或“网格图”显示类型。But where the aggregation type is Average, choose the Line or Grid display types.

如果在应用中编写了自定义指标并且这些指标包含属性值,可以在列表中选择该属性。If you coded custom metrics into your app and they include property values, you'll be able to select the property in the list.

图表是否对分段的数据而言太小?Is the chart too small for segmented data? 调整图表高度:Adjust its height:

调整滑块

聚合类型Aggregation types

旁边的图例通常默认显示图表在这段期间的聚合值。The legend at the side by default usually shows the aggregated value over the period of the chart. 如果将鼠标悬停在图表上,会显示该点的值。If you hover over the chart, it shows the value at that point.

图表上的每个数据点是在以前采样间隔或“粒度”中所收到的数据值聚合。Each data point on the chart is an aggregate of the data values received in the preceding sampling interval or "granularity". 粒度显示在边栏选项卡顶部,随着图表的时幅而有所不同。The granularity is shown at the top of the blade, and varies with the overall timescale of the chart.

指标可以用不同方式聚合:Metrics can be aggregated in different ways:

  • 计数是在采样间隔中接收的事件的计数。Count is a count of the events received in the sampling interval. 它用于诸如请求这类的事件。It is used for events such as requests. 图表高度的变化指示事件发生速率的变化。Variations in the height of the chart indicates variations in the rate at which the events occur. 但请注意,数值会在更改采样间隔时更改。But note that the numeric value changes when you change the sampling interval.
  • 总和:将采样间隔或图表期间收到的所有数据点的值相加。Sum adds up the values of all the data points received over the sampling interval, or the period of the chart.
  • 平均:将总和除以间隔期间收到的数据点数目。Average divides the Sum by the number of data points received over the interval.
  • 唯一计数:用于用户和帐户的计数。Unique counts are used for counts of users and accounts. 在采样间隔或图表期间,图形显示在该时间看到的不同用户的计数。Over the sampling interval, or over the period of the chart, the figure shows the count of different users seen in that time.
  • % - 每个聚合的百分比版本仅用于分段图表。% - percentage versions of each aggregation are used only with segmented charts. 总计始终加起来等于 100%,图表显示总计的不同组成部分的相对比例。The total always adds up to 100%, and the chart shows the relative contribution of different components of a total.

    百分比聚合

更改聚合类型Change the aggregation type

编辑图表,并选择聚合

创建新图表或取消选择所有指标时,系统会显示每个指标的默认方法:The default method for each metric is shown when you create a new chart or when all metrics are deselected:

取消选择所有指标可查看默认值

固定 Y 轴Pin Y-axis

默认情况下,图表显示的 Y 轴值从零开始一直到数据范围中的最大值,通过可视化方式表现值的份额。By default a chart shows Y axis values starting from zero till maximum values in the data range, to give a visual representation of quantum of the values. 但在某些情况下,除了份额外,通过可视化方式检查值的细微变化可能也很有趣。But in some cases more than the quantum it might be interesting to visually inspect minor changes in values. 为了达到此类自定义效果,请使用 Y 轴范围编辑功能将 Y 轴的最小值或最大值固定在所需位置。For customizations like this use the Y-axis range editing feature to pin the Y-axis minimum or maximum value at desired place. 单击“高级设置”复选框,显示 Y 轴范围设置Click on "Advanced Settings" check box to bring up the Y-axis range Settings

单击“高级设置”,选择“自定义范围”,并指定最值

筛选数据Filter your data

若只要查看选定的一组属性值的指标:To see just the metrics for a selected set of property values:

单击“筛选”,展开某个属性,并检查一些值

如果未为特定属性选择任何值,就相当于将它们全部选中:不对该属性使用筛选。If you don't select any values for a particular property, it's the same as selecting them all: there is no filter on that property.

请注意每个属性值旁边的事件计数。Notice the counts of events alongside each property value. 选择一个属性的值时,计数以及其他属性值会调整。When you select values of one property, the counts alongside other property values are adjusted.

筛选器将应用到边栏选项卡上的所有图表。Filters apply to all the charts on a blade. 如果要将不同的筛选器应用到不同的图表,请创建并保存不同的指标边栏选项卡。If you want different filters applied to different charts, create and save different metrics blades. 如果需要,可将不同边栏选项卡中的图表固定到仪表板,以便并排查看这些图表。If you want, you can pin charts from different blades to the dashboard, so that you can see them alongside each other.

删除 Bot 和 Web 测试流量Remove bot and web test traffic

使用筛选器“实际或综合流量”并选中“实际”。Use the filter Real or synthetic traffic and check Real.

也可以按“综合流量的源”筛选。You can also filter by Source of synthetic traffic.

将属性添加到筛选列表To add properties to the filter list

想要根据自己选择的类别筛选遥测数据?Would you like to filter telemetry on a category of your own choosing? 例如,要将用户划分到不同的类别,并根据这些类别将数据分段。For example, maybe you divide up your users into different categories, and you would like segment your data by these categories.

创建自己的属性Create your own property. 遥测初始值设定项中设置,使其显示在所有遥测中 - 包括不同 SDK 模块发送的标准遥测。Set it in a Telemetry Initializer to have it appear in all telemetry - including the standard telemetry sent by different SDK modules.

编辑图表类型Edit the chart type

请注意,可以在网格与图形之间切换:Notice that you can switch between grids and graphs:

选择网格或图形,并选择图表类型

保存指标边栏选项卡Save your metrics blade

创建一些图表后,可将它们保存到收藏夹。When you've created some charts, save them as a favorite. 如果使用组织帐户,可以选择是否要将图表与其他团队成员共享。You can choose whether to share it with other team members, if you use an organizational account.

选择收藏夹

若要再次查看边栏选项卡,请转到概览边栏选项卡并打开“收藏夹”:To see the blade again, go to the overview blade and open Favorites:

在概览边栏选项卡中选择“收藏夹”

如果保存时选择了“相对”时间范围,将使用最新指标更新边栏选项卡。If you chose Relative time range when you saved, the blade will be updated with the latest metrics. 如果选择了“绝对”时间范围,边栏选项卡每次都显示相同的数据。If you chose Absolute time range, it will show the same data every time.

重置边栏选项卡Reset the blade

如果编辑了某个边栏选项卡,但后来想要还原到原始的保存集,单击“重置”即可。If you edit a blade but then you'd like to get back to the original saved set, just click Reset.

在指标资源管理器顶部的按钮中

实时指标流Live metrics stream

若要更直观的观察遥测,请打开实时流For a much more immediate view of your telemetry, open Live Stream. 由于聚合过程,大多数指标需要几分钟才会显示。Most metrics take a few minutes to appear, because of the process of aggregation. 相比之下,实时指标为实现低延迟进行了优化。By contrast, live metrics are optimized for low latency.

设置警报Set alerts

若要收到任意指标异常值的电子邮件通知,请添加警报。To be notified by email of unusual values of any metric, add an alert. 可选择将电子邮件发送给帐户管理员或特定电子邮件地址。You can choose either to send the email to the account administrators, or to specific email addresses.

在指标资源管理器中选择“警报规则”,并选择“添加警报”

详细了解警报Learn more about alerts.

连续导出Continuous Export

如果想要连续导出数据以便在外部进行处理,请考虑使用连续导出If you want data continuously exported so that you can process it externally, consider using Continuous export.

Power BIPower BI

如果想要获得数据的更丰富视图,可以导出到 Power BIIf you want even richer views of your data, you can export to Power BI.

分析Analytics

Analytics 是使用强大查询语言来分析遥测数据的更灵活方式。Analytics is a more versatile way to analyze your telemetry using a powerful query language. 如果想要合并或计算指标的结果或执行应用程序近期性能的深入分析,可以使用该功能。Use it if you want to combine or compute results from metrics, or perform an in-depth exploration of your app's recent performance.

在指标图表中,可以单击“分析”图标,直接访问等效的分析查询。From a metric chart, you can click the Analytics icon to get directly to the equivalent Analytics query.

故障排除Troubleshooting

图表中未显示任何数据。I don't see any data on my chart.

  • 筛选器将应用到边栏选项卡中的所有图表。Filters apply to all the charts on the blade. 将焦点放在某个图表上时,请确保未在其他图表上设置会排除所有数据的筛选器。Make sure that, while you're focusing on one chart, you didn't set a filter that excludes all the data on another.

    如果想要在不同的图表上设置不同的筛选器,请在不同的边栏选项卡中创建图表,将它们保存为独立的收藏项。If you want to set different filters on different charts, create them in different blades, save them as separate favorites. 如果需要,可将这些图表固定到仪表板,以便并排查看这些图表。If you want, you can pin them to the dashboard so that you can see them alongside each other.

  • 如果根据指标上未定义的属性将图表分组,则图表中不会显示任何数据。If you group a chart by a property that is not defined on the metric, then there will be nothing on the chart. 请尝试清除“分组依据”,或选择不同的分组属性。Try clearing 'group by', or choose a different grouping property.
  • 性能数据(CPU、IO 速率等)适用于 Java Web 服务、Windows 桌面应用、IIS Web 应用和服务(如果安装了状态监视器)以及 Azure 云服务Performance data (CPU, IO rate, and so on) is available for Java web services, Windows desktop apps, IIS web apps and services if you install status monitor, and Azure Cloud Services. 这些数据不适用于 Azure 网站。It isn't available for Azure websites.

视频Video

后续步骤Next steps