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

Azure 指标资源管理器的高级功能Advanced features of Azure Metrics Explorer


本文假定使用者熟悉指标资源管理器的基本功能。This article assumes that you are familiar with basic features of Metrics Explorer. 如果你是新用户,希望了解如何创建第一个指标图表,请参阅 Azure 指标资源管理器入门If you are a new user and want to learn how to create your first metric chart, see Getting started with Azure Metrics Explorer.

Azure 中的指标Metrics in Azure

Azure Monitor 中的指标是随着时间的推移收集和存储的一系列测量值和计数。Metrics in Azure Monitor are the series of measured values and counts that are collected and stored over time. 有标准(或“平台”)指标和自定义指标。There are standard (or “platform”) metrics, and custom metrics. 标准指标由 Azure 平台本身提供。The standard metrics are provided to you by the Azure platform itself. 标准指标反映 Azure 资源的运行状况和使用情况统计信息。Standard metrics reflect the health and usage statistics of your Azure resources. 而自定义指标是由应用程序通过用于自定义事件和指标的 Application Insights APIWindows Azure 诊断 (WAD) 扩展Azure Monitor REST API 发送给 Azure 的。Whereas custom metrics are sent to Azure by your applications using the Application Insights API for custom events and metrics, Windows Azure Diagnostics (WAD) extension, or by Azure Monitor REST API.

使用多个指标和图表创建视图Create views with multiple metrics and charts

可以创建一次绘制多个指标行或显示多个指标图表的图表。You can create charts that plot multiple metrics lines or show multiple metric charts at once. 此功能用于:This functionality allows you to:

  • 将同一图形中的相关指标关联到一起,看一个值如何与另一个值相关联。correlate related metrics on the same graph to see how one value is related to another
  • 显示很临近但具有不同度量单位的指标display metrics with different units of measure in close proximity
  • 以视觉方式聚合和比较来自多个源的指标visually aggregate and compare metrics from multiple resources

例如,你有 5 个存储帐户,想要知道在其中消耗了多少总空间,则可创建一个(堆积的)面积图表,以便显示特定时间点的各个值以及所有值的总计。For example, if you have 5 storage accounts and you want to know how much total space is consumed between them, you can create a (stacked) area chart which shows the individual and sum of all the values at particular points in time.

同一图表上的多个指标Multiple metrics on the same chart

首先,创建新图表First, create a new chart. 单击“添加指标”,然后通过同样的步骤在同一图表上添加另一指标。Click Add Metric and repeat the steps to add another metric on the same chart.


通常情况下,你不会想要在一个图表上拥有度量单位不同(即“毫秒”和“千字节”)或刻度差异显著的多个指标。You typically don’t want to have metrics with different units of measure (i.e. “milliseconds” and “kilobytes”) or with significantly different scale on one chart. 此时,可考虑使用多个图表。Instead, consider using multiple charts. 单击“添加图表”按钮,即可在指标资源管理器中创建多个图表。Click on the Add Chart button to create multiple charts in metrics explorer.

多个图表Multiple charts

单击“添加图表”,使用另一指标创建另一图表。Click the Add chart and create another chart with a different metric.

将多个图表排序或将其删除Order or delete multiple charts

若要将多个图表排序或将其删除,请单击省略号 ( ... ),以便打开图表菜单并选择适当的菜单项:向上移动向下移动删除To order or delete multiple charts, click on the ellipses ( ... ) symbol to open the chart menu and choose the appropriate menu item of Move up, Move down, or Delete.

更改聚合Changing aggregation

将指标添加到图表时,指标资源管理器会自动预先选择其默认聚合。When you add a metric to a chart, metrics explorer automatically pre-selects its default aggregation. 默认值在基本方案中适用,但可以使用不同的聚合来获得有关指标的其他见解。The default makes sense in the basic scenarios, but you can use a different aggregation to gain additional insights about the metric. 查看图表上的不同聚合时需要了解指标资源管理器处理它们的方式。Viewing different aggregations on a chart requires that you understand how metrics explorer handles them.

指标是在一段时间内捕获的一系列度量(或“度量值”)。Metrics are the series of measurements (or "metric values") captured over the time period. 绘制图表时,所选指标的值将基于时间粒度进行单独聚合。When you plot a chart, the values of the selected metric are separately aggregated over the time grain. 使用指标资源管理器时间选取器面板选择时间粒度的大小。You select the size of the time grain using the Metrics Explorer time picker panel. 如果没有显式选择时间粒度,则会根据当前选择的时间范围自动选择时间粒度。If you don’t make an explicit selection of the time grain, the time granularity is automatically selected based on the currently selected time range. 确定时间粒度后,在每个时间粒度间隔期间捕获的指标值将聚合并放置在图表上 - 每个时间粒度一个数据点。Once the time grain is determined, the metric values that were captured during each time grain interval are aggregated and placed onto the chart - one datapoint per time grain.

例如,假设图表针对“过去 24 小时”时间跨度使用“Average”聚合来显示“服务器响应时间”指标 :For example, suppose the chart is showing the Server Response Time metric using the Average aggregation over the last 24 hours time span:

  • 如果时间粒度设置为 30 分钟,则从 48 个聚合数据点绘制图表(例如,折线图连接图表绘图区域中的 48 个点)。If the time granularity is set to 30 minutes, the chart is drawn from 48 aggregated datapoints (e.g. the line chart connects 48 dots in the chart plot area). 即 24 小时 x 每小时 2 个数据点。That is, 24 hours x 2 datapoints per hour. 每个数据点表示在每个相关的 30 分钟时间段内发生的服务器请求的所有捕获响应时间的平均值。Each datapoint represents the average of all captured response times for server requests that occurred during each of the relevant 30 min time periods.
  • 如果将时间粒度切换到 15 分钟,将获得 96 个聚合数据点。If you switch the time granularity to 15 minutes, you get 96 aggregated datapoints. 即 24 小时 x 每小时 4 个数据点。That is, 24 hours x 4 datapoints per hour.

指标资源管理器中提供了五种基本的统计信息聚合类型:Sum、Count、Min、Max 和 Average 。There are five basic stats aggregation types available in the metrics explorer: Sum, Count, Min, Max, and Average. “Sum”聚合有时称为“Total”聚合 。The Sum aggregation is sometimes referred as Total aggregation. 对于许多指标,指标资源管理器将隐藏完全不相关且无法使用的聚合。For many metrics, Metrics Explorer will hide the aggregations that are totally irrelevant and cannot be used.

  • Sum –聚合间隔内捕获的所有值的总和Sum – the sum of all values captured over the aggregation interval
  • Count –通过聚合间隔捕获的度量值的数量。Count – the number of measurements captured over the aggregation interval. 请注意,在捕获的指标值始终为 1 的情况下,“Count”将等于“Sum” 。Note that Count will be equal to Sum in the case where the metric is always captured with the value of 1. 当指标跟踪不同事件的计数,并且每个度量表示一个事件时(即每次新请求传入时,代码都会触发指标记录),这种情况很常见This is common when the metric tracks the count of distinct events, and each measurement represents one event (i.e. the code fires off a metric record every time a new request comes in)
  • Average –通过聚合间隔捕获的指标值的平均值Average – the average of the metric values captured over the aggregation interval
  • Min –聚合间隔内捕获的最小值Min – the smallest value captured over the aggregation interval
  • Max –聚合间隔内捕获的最大值Max – the largest value captured over the aggregation interval

向图表应用筛选器Apply filters to charts

可以将筛选器应用到显示多维指标的图表。You can apply filters to the charts that show metrics with dimensions. 例如,如果指标“事务计数”具有指示事务的响应成功与否的维度“响应类型”,则在此维度上进行筛选将只绘制成功(或失败)事务的折线图。For example, if the metric “Transaction count” has a dimension, “Response type”, which indicates whether the response from transactions succeeded or failed then filtering on this dimension would plot a chart line for only successful (or only failed) transactions.

添加筛选器To add a filter

  1. 选择图表上方的“添加筛选器”Select Add filter above the chart

  2. 选择想要筛选的维度(属性)Select which dimension (property) you want to filter


  3. 选择想要在绘制图表时包含的维度值(此示例将显示筛选出了成功的存储事务):Select which dimension values you want to include when plotting the chart (this example shows filtering out the successful storage transactions):


  4. 选择筛选值后,在“筛选选择器”之外单击将其关闭。After selecting the filter values, click away from the Filter Selector to close it. 现在图表将显示失败的存储事务数:Now the chart shows how many storage transactions have failed:


  5. 可以重复步骤 1-4 将多个筛选器应用到同一个图表。You can repeat steps 1-4 to apply multiple filters to the same charts.

对图表应用拆分Apply splitting to a chart

可以按维度拆分指标,以直观地显示指标不同部分之间的差异,并标识出某个维度的边远部分。You can split a metric by dimension to visualize how different segments of the metric compare against each other, and identify the outlying segments of a dimension.

应用拆分Apply splitting

  1. 单击图表上方的“应用拆分”。Click on Apply splitting above the chart.


    不能对包含多个指标的图表使用拆分。Splitting cannot be used with charts that have multiple metrics. 另外,你可以有多个筛选器,但只能对任何单个图表应用一个拆分维度。Also, you can have multiple filters but only one splitting dimension applied to any single chart.

  2. 选择想要用于分割图表的维度:Choose a dimension on which you want to segment your chart:


    现在图表将显示多个折线图,每个维度部分均有一个:Now the chart now shows multiple lines, one for each segment of dimension:


  3. 在“分组选择器”之外单击以将其关闭。Click away from the Grouping Selector to close it.


    在同一个维度上同时使用筛选和拆分,可以隐藏与你的方案无关的部分,使图表更易读取。Use both Filtering and Splitting on the same dimension to hide the segments that are irrelevant for your scenario and make charts easier to read.

锁定图表 y 轴的边界Lock boundaries of chart y-axis

当图表显示较大值的较小波动时,锁定 y 轴的范围变得很重要。Locking the range of the y-axis becomes important when the chart shows smaller fluctuations of larger values.

例如,如果成功请求的数量从 99.99% 下降到 99.5%,这可能表示服务质量显著降低。For example, when the volume of successful requests drops down from 99.99% to 99.5%, it may represent a significant reduction in the quality of service. 不过,使用默认的图表设置时,观察小的数值波动很困难,甚至不可能实现。However, noticing a small numeric value fluctuation would be difficult or even impossible from the default chart settings. 在这种情况下,你可以将图表的最低边界锁定到 99%,这将使此较小的降低更加明显。In this case you could lock the lowest boundary of the chart to 99%, which would make this small drop more apparent.

另一个示例是可用内存的波动,其中的值在技术上永远不会达到 0。Another example is a fluctuation in the available memory, where the value will technically never reach 0. 将范围固定到一个较高的值可以使可用内存的降低更容易被发现。Fixing the range to a higher value may make the drops in available memory easier to spot.

若要控制 y 轴范围,请使用 “…”To control the y-axis range, use the “…” 图表菜单,并选择“编辑图表”以访问高级图表设置。chart menu, and select Edit chart to access advanced chart settings. 修改“Y 轴范围”部分中的值,或者使用“自动”按钮恢复为默认值。Modify the values in the Y-Axis Range section, or use Auto button to revert to defaults.



如果图表用于跟踪一段时间内的各种计数或合计(并因此使用计数、求和、最小值或最大值聚合),要锁定这类图表的 y 轴边界,通常需要指定一个固定的时间粒度,而不是依赖于自动默认值。Locking the boundaries of y-axis for the charts that track various counts or sums over a period of time (and thus use count, sum, minimum, or maximum aggregations) usually requires specifying a fixed time granularity rather than relying on the automatic defaults. 这是必要的,因为当用户通过调整浏览器窗口大小或者通过更改屏幕分辨率来自动修改时间粒度时,图表上的值也会发生更改。This is necessary is because the values on charts change when the time granularity is automatically modified by the user resizing browser window or going from one screen resolution to another. 时间粒度发生的更改会影响图表的外观,导致当前选择的 y 轴范围失效。The resulting change in time granularity effects the look of the chart, invalidating current selection of y-axis range.

更改图表线条的颜色Change colors of chart lines

配置图表后,将从默认调色板自动为图表线条分配颜色。After you configure the charts, the chart lines are automatically assigned a color from a default palette. 可以更改这些颜色。You can change those colors.

若要更改图表线条的颜色,请单击与图表相对应的图例中的彩色条。To change the color of a chart line, click on the colored bar in the legend that corresponds to the chart. 这将打开“颜色选取器”对话框。The color picker dialog will open. 使用颜色选取器配置线条的颜色。Use the color picker to configure the color for the line.

配置图表颜色后,将图表固定到仪表板时,它们将保持此配置。After the chart colors are configured, they will remain that way when you pin the chart to a dashboard. 以下部分说明如何固定图表。The following section shows you how to pin a chart.


将图表固定到仪表板Pin charts to dashboards

配置图表后,可能需要将其添加到仪表板,以便可以再次查看它(可能是在其他监视遥测的上下文中)或与团队共享。After configuring the charts, you may want to add it to the dashboards so that you can view it again, possibly in context of other monitoring telemetry, or share with your team.

将配置的图表固定到仪表板:To pin a configured chart to a dashboard:

配置图表后,单击图表右上角的“图表操作”菜单,然后单击“固定到仪表板”。After configuring your chart, click on the Chart Actions menu in the right top corner of the chart, and click Pin to dashboard.


创建警报规则Create alert rules

可以使用设置的条件将指标可视化为基于指标的警报规则的基础。You can use the criteria you have set to visualize your metrics as the basis of a metric based alert rule. 新的警报规则将包括图表的目标资源、指标、拆分和筛选器维度。The new alerting rule will include your target resource, metric, splitting, and filter dimensions from your chart. 稍后将能够在警报规则创建窗格上修改这些设置。You will be able to modify these settings later on the alert rule creation pane.

单击“新建警报规则”,创建新的警报规则To create a new alert rule, click New Alert rule


则会转到警报规则创建窗格,其中预先填充了来自你的图表的底层指标维度,以便更轻松地生成自定义警报规则。You will be taken to the alert rule creation pane with the underlying metric dimensions from your chart pre-populated to make it easier to generate custom alert rules.


若要详细了解如何设置指标警报,请查看此文章Check out this article to learn more about setting up metric alerts.


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

  • 筛选器将应用到窗格中的所有图表。Filters apply to all the charts on the pane. 将焦点放在某个图表上时,请确保未在其他图表上设置会排除所有数据的筛选器。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 segment a chart by a property that is not defined on the metric, then there will be nothing on the chart. 请尝试清除分段(拆分),或选择其他属性。Try clearing the segmentation (splitting), or choose a different property.

后续步骤Next steps

请参阅创建自定义 KPI 仪表板,了解使用指标创建可操作仪表板的最佳实践。Read Creating custom KPI dashboards to learn about the best practices for creating actionable dashboards with metrics.