Azure 指标资源管理器的高级功能Advanced features of the Azure metrics explorer

备注

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

在 Azure Monitor 中,指标是随着时间的推移收集和存储的一系列度量值和计数。In Azure Monitor, metrics are a series of measured values and counts that are collected and stored over time. 指标可以是标准(也称为“平台”)指标,也可以是自定义指标。Metrics can be standard (also called "platform") or custom.

标准指标由 Azure 平台提供,Standard metrics are provided by the Azure platform. 反映 Azure 资源的运行状况和使用情况统计信息。They reflect the health and usage statistics of your Azure resources.

资源范围选取器Resource scope picker

使用资源范围选取器,你可以查看单个资源和多个资源的指标。The resource scope picker allows you to view metrics across single resources and multiple resources. 以下部分介绍如何使用资源范围选取器。The following sections explain how to use the resource scope picker.

选择单个资源Select a single resource

从 Azure Monitor 菜单或从资源的菜单的“监视”部分选择“指标” 。Select Metrics from the Azure Monitor menu or from the Monitoring section of a resource's menu. 然后选择“选择范围”以打开范围选取器。Then choose Select a scope to open the scope picker.

使用范围选取器选择要查看其指标的资源。Use the scope picker to select the resources whose metrics you want to see. 如果从资源的菜单中打开了 Azure 指标资源管理器,则该范围应已填充完毕。The scope should be populated if you opened the Azure metrics explorer from a resource's menu.

屏幕截图,显示如何打开资源范围选取器。

对于某些资源,一次只能查看一个资源的指标。For some resources, you can view only one resource's metrics at a time. 在“资源类型”菜单中,这些资源位于“所有资源类型”部分。 In the Resource types menu, these resources are in the All resource types section.

屏幕截图,显示单个资源。

选择资源后,会看到包含该资源的所有订阅和资源组。After selecting a resource, you see all subscriptions and resource groups that contain that resource.

屏幕截图,显示可用资源。

提示

如果需要同时查看多个资源的指标的功能,或查看整个订阅或资源组的指标的功能,请选择“投票赞成”。If you want the capability to view the metrics for multiple resources at the same time, or to view metrics across a subscription or resource group, select Upvote.

选好之后,请选择“应用”。When you're satisfied with your selection, select Apply.

查看多个资源的指标View metrics across multiple resources

某些资源类型可以查询多个资源的指标。Some resource types can query for metrics over multiple resources. 这些资源必须位于相同的订阅和位置中。The resources must be within the same subscription and location. 可以在“资源类型”菜单顶部找到这些资源类型。Find these resource types at the top of the Resource types menu.

屏幕截图,显示跨资源的类型。

对于兼容多个资源的类型,你可以查询跨订阅或跨多个资源组的指标。For types that are compatible with multiple resources, you can query for metrics across a subscription or multiple resource groups.

多个指标行和图表Multiple metric lines and charts

在 Azure 指标资源管理器中,可以创建绘制多个指标行的图表或同时显示多个指标图表。In the Azure metrics explorer, you can create charts that plot multiple metric lines or show multiple metric charts at the same time. 此功能用于:This functionality allows you to:

  • 将同一个图中的相关指标关联到一起,了解一个值如何与另一个值相关联。Correlate related metrics on the same graph to see how one value relates to another.
  • 以邻近的方式显示使用不同度量单位的指标。Display metrics that use different units of measure in close proximity.
  • 直观地聚合和比较来自多个资源的指标。Visually aggregate and compare metrics from multiple resources.

例如,假设你有 5 个存储帐户,想知道它们一起使用了多少空间。For example, imagine you have five storage accounts, and you want to know how much space they consume together. 你可以创建一个(堆积的)面积图表,以便显示特定时间点的各个值以及所有值的总计。You can create a (stacked) area chart that shows the individual values and the sum of all the values at particular points in time.

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

若要在同一个图表中查看多个指标,请首先创建新的图表To view multiple metrics on the same chart, first create a new chart. 然后选择“添加指标”。Then select Add metric. 通过同样的步骤在同一图表上添加另一指标。Repeat this step to add another metric on the same chart.

备注

通常,图表不应混合那些使用不同度量单位的指标。Typically, your charts shouldn't mix metrics that use different units of measure. 例如,应避免将一个使用毫秒的指标与另一个使用千字节的指标混合使用。For example, avoid mixing one metric that uses milliseconds with another that uses kilobytes. 还应避免混合使用尺度差别很大的指标。Also avoid mixing metrics whose scales differ significantly.

在这些情况下,请考虑改用多个图表。In these cases, consider using multiple charts instead. 在指标资源管理器中,选择“新建图表”以创建新的图表。In the metrics explorer, select New chart to create a new chart.

多个图表Multiple charts

若要使用另一指标创建另一图表,请选择“新建图表”。To create another chart that uses a different metric, select New chart.

若要对多个图表重新排序或将其删除,请选择省略号 ( ... ) 按钮以打开图表菜单。To reorder or delete multiple charts, select the ellipsis (...) button to open the chart menu. 然后,选择“上移”、“下移”或“删除”。Then choose Move up, Move down, or Delete.

时间范围控件Time range controls

除了使用时间选取器面板来更改时间范围外,还可以使用图表区中的控件进行平移和缩放。In addition to changing the time range using the time picker panel, you can also pan and zoom using the controls in the chart area.

平移Pan

若要平移,请单击图表边缘的向左和向右箭头。To pan, click on the left and right arrows at the edge of the chart. 这会将选定的时间范围前后移动图表的时间跨度的一半。This will move the selected time range back and forward by one half the chart's time span. 例如,如果你正在查看过去 24 小时,单击左箭头将导致时间范围转换为一天半至 12 小时前。For example, if you're viewing the past 24 hours, clicking on the left arrow will cause the time range to shift to span a day and a half to 12 hours ago.

大多数指标支持 93 天的保留期,但一次只能查看 30 天。Most metrics support 93 days of retention but only let you view 30 days at a time. 使用平移控件,可以查看过去 30 天的内容,并可以一次轻松后退 15 天,以查看保留期的剩余部分。Using the pan controls, you look at the past 30 days and then easily walk back 15 days at a time to view the rest of the retention period.

动态 gif 显示左平移和右平移控件。

缩放Zoom

你可以在图表上单击并拖动以放大图表中的某个部分。You can click and drag on the chart to zoom into a section of a chart. 缩放将按照你选择的范围更新图表的时间范围,并且如果将时间粒度设置为“自动”,将选择较小的时间粒度。Zooming will update the chart's time range to span your selection and will select a smaller time grain if the time grain is set to "Automatic". 新时间范围将应用于指标中的所有图表。The new time range will apply to all charts in Metrics.

显示指标缩放功能的动态 gif。

聚合Aggregation

将指标添加到图表时,指标资源管理器会自动应用默认聚合。When you add a metric to a chart, the metrics explorer automatically applies a default aggregation. 默认设置在基本方案中是合理的。The default makes sense in basic scenarios. 但是,你可以使用另一聚合来获得有关此指标的更多见解。But you can use a different aggregation to gain more insights about the metric.

在图表上使用不同的聚合之前,应了解指标资源管理器处理它们的方式。Before you use different aggregations on a chart, you should understand how the metrics explorer handles them. 指标是在一段时间内捕获的一系列度量(或“指标值”)。Metrics are a series of measurements (or "metric values") that are captured over a 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 by using the metrics explorer's time picker panel. 如果没有显式选择时间粒度,则默认使用当前选择的时间范围。If you don't explicitly select the time grain, the currently selected time range is used by default. 确定时间粒度后,在每个时间粒度期间捕获的指标值会聚合在图表上,每个时间粒度一个数据点。After the time grain is determined, the metric values that were captured during each time grain are aggregated on the chart, one data point per time grain.

例如,假设图表显示“服务器响应时间”指标。For example, suppose a chart shows the Server response time metric. 它针对“过去 24 小时”的时间跨度使用“平均值”聚合。 It uses the average aggregation over time span of the last 24 hours. 在本示例中:In this example:

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

指标资源管理器有五个基本的统计聚合类型:总和、计数、最小值、最大值和平均值。The metrics explorer has five basic statistical aggregation types: sum, count, min, max, and average. “总和”聚合有时称为“总计”聚合 。The sum aggregation is sometimes called the total aggregation. 对于许多指标,指标资源管理器会隐藏不相关且无法使用的聚合。For many metrics, the metrics explorer hides the aggregations that are irrelevant and can't be used.

  • 总和:在聚合间隔期间捕获的所有值的总和。Sum: The sum of all values captured during the aggregation interval.

    “总和”请求的屏幕截图。

  • 计数:在聚合间隔期间捕获的度量数。Count: The number of measurements captured during the aggregation interval.

    当捕获的指标的值始终为 1 时,计数聚合等于总和聚合。When the metric is always captured with the value of 1, the count aggregation is equal to the sum aggregation. 当指标跟踪不同事件的计数,并且每个度量表示一个事件时,这种情况很常见。This scenario is common when the metric tracks the count of distinct events and each measurement represents one event. 每当一个新请求到达时,代码都会发出一个指标记录。The code emits a metric record every time a new request arrives.

    “计数”请求的屏幕截图。

  • Average:在聚合间隔期间捕获的指标值的平均值。Average: The average of the metric values captured during the aggregation interval.

    “平均值”请求的屏幕截图。

  • 最小值:在聚合间隔期间捕获的最小值。Min: The smallest value captured during the aggregation interval.

    “最小值”请求的屏幕截图。

  • 最大值:在聚合间隔期间捕获的最大值。Max: The largest value captured during the aggregation interval.

    “最大值”请求的屏幕截图。

筛选器Filters

可以将筛选器应用到其指标有多个维度的图表。You can apply filters to charts whose metrics have dimensions. 例如,假设有一个具有“响应类型”维度的“事务计数”指标。For example, imagine a "Transaction count" metric that has a "Response type" dimension. 此维度指示来自事务的响应成功了还是失败了。This dimension indicates whether the response from transactions succeeded or failed. 如果在此维度上进行筛选,则会看到只绘制成功(或失败)事务的图表线条。If you filter on this dimension, you'll see a chart line for only successful (or only failed) transactions.

添加筛选器Add a filter

  1. 在图表上方选择“添加筛选器”。Above the chart, select Add filter.

  2. 选择要筛选的维度(属性)。Select a dimension (property) to filter.

    该屏幕截图显示了可筛选的维度(属性)。

  3. 选择要对维度(属性)应用的运算符。Select the operator you want to apply against the dimension (property). 默认运算符为 =(等于)The default operator is = (equals)

    显示可与筛选器结合使用的运算符的屏幕截图。

  4. 选择在绘制图表时要应用于筛选器的维度值(本示例显示筛选出了成功的存储事务):Select which dimension values you want to apply to the filter when plotting the chart (this example shows filtering out the successful storage transactions):

    屏幕截图,显示已筛选的成功的存储事务。

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

    屏幕截图,显示已失败的存储事务数。

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

指标拆分Metric splitting

可以按维度拆分指标,将指标的不同部分进行直观比较。You can split a metric by dimension to visualize how different segments of the metric compare. 拆分还有助于标识某个维度的无关段。Splitting can also help you identify the outlying segments of a dimension.

应用拆分Apply splitting

  1. 在图表上方选择“应用拆分”。Above the chart, select Apply splitting.

    备注

    包含多个指标的图表不能使用拆分功能。Charts that have multiple metrics can't use the splitting functionality. 此外,一个图表可以有多个筛选器,但只能有一个拆分维度。Also, although a chart can have multiple filters, it can have only one splitting dimension.

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

    屏幕截图,显示细分图表所依据的选定维度。

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

    该屏幕截图显示了多个折线图,每个维度部分均有一个。

  3. 选择在按选定维度拆分后要显示的值数限制。Choose a limit on the number of values to be displayed after splitting by selected dimension. 默认限制为 10,如上图所示。The default limit is 10 as shown in the above chart. 限制范围为 1-50。The range of limit is 1 - 50.

    显示拆分限制(用于限制拆分后的值数)的屏幕截图。

  4. 选择段的排序顺序:升序或降序。Choose the sort order on segments: Ascending or Descending. 默认选择为降序。The default selection is descending.

    显示拆分值排序顺序的屏幕截图。

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

    备注

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

锁定 y 轴的范围Locking the range of the y-axis

在大值出现小波动的图表中,锁定值轴(y 轴)的范围变得很重要。Locking the range of the value (y) axis becomes important in charts that show small fluctuations of large values.

例如,如果成功请求的比例从 99.99% 降到 99.5%,则可能表示服务质量显著降低。For example, a drop in the volume of successful requests from 99.99 percent to 99.5 percent might represent a significant reduction in the quality of service. 但是,如果使用默认的图表设置,则观察小的数值波动会很困难,甚至不可能实现。But noticing a small numeric value fluctuation would be difficult or even impossible if you're using the default chart settings. 在这种情况下,你可以将图表的最低边界锁定为 99%,使较小的降低幅度变得更明显。In this case, you could lock the lowest boundary of the chart to 99 percent to make a small drop more apparent.

另一个示例是可用内存的波动。Another example is a fluctuation in the available memory. 从技术上来说,这种情况下的值永远不会达到 0。In this scenario, the value will technically never reach 0. 将范围固定为一个较高的值可以使可用内存的降低更容易被发现。Fixing the range to a higher value might make drops in available memory easier to spot.

若要控制 y 轴范围,请打开图表菜单 (...)。然后,选择“图表设置”以访问高级图表设置。To control the y-axis range, open the chart menu (...). Then select Chart settings to access advanced chart settings.

屏幕截图,突出显示“图表设置”选项。

修改“Y 轴范围”部分的值,或者选择“自动”恢复为默认值。 Modify the values in the Y-axis range section, or select Auto to revert to the default values.

突出显示 Y 轴范围部分的屏幕截图。

警告

如果图表用于跟踪一段时间内的计数或总和(通过使用计数、总和、最小值或最大值聚合的方式),而你需要锁定这类图表的 y 轴边界,则通常应指定一个固定的时间粒度。If you need to lock the boundaries of the y-axis for charts that track counts or sums over a period of time (by using count, sum, min, or max aggregations), you should usually specify a fixed time granularity. 在这种情况下,不应依赖于自动默认设置。In this case, you shouldn't rely on the automatic defaults.

之所以选择固定的时间粒度,是因为当用户通过重设浏览器窗口大小或更改屏幕分辨率来自动修改时间粒度时,图表值会发生更改。You choose a fixed time granularity because chart values change when the time granularity is automatically modified after a user resizes a browser window or changes screen resolution. 时间粒度发生的更改会影响图表的外观,导致当前选择的 y 轴范围失效。The resulting change in time granularity affects the look of the chart, invalidating the current selection of the y-axis range.

线条颜色Line colors

配置图表后,将从默认调色板自动为图表线条分配颜色。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, select the colored bar in the legend that corresponds to the chart. 此时会打开颜色选取器对话框。The color picker dialog box opens. 使用颜色选取器配置线条颜色。Use the color picker to configure the line color.

屏幕截图,显示如何更改颜色。

将图表固定到仪表板时,会保留自定义颜色。Your customized colors are preserved when you pin the chart to a dashboard. 以下部分说明如何固定图表。The following section shows how to pin a chart.

固定到仪表板Pinning to dashboards

配置图表后,可能需要将其添加到仪表板。After you configure a chart, you might want to add it to a dashboard. 图表固定到仪表板后即可供团队访问。By pinning a chart to a dashboard, you can make it accessible to your team. 还可以通过在其他监视遥测的上下文中查看它来获得见解。You can also gain insights by viewing it in the context of other monitoring telemetry.

若要将配置的图表固定到仪表板,请在图表右上角选择“固定到仪表板”。To pin a configured chart to a dashboard, in the upper-right corner of the chart, select Pin to dashboard.

屏幕截图,显示如何将图表固定到仪表板。

警报规则Alert rules

可以使用可视化条件来创建基于指标的警报规则。You can use your visualization criteria to create a metric-based alert rule. 新的警报规则会包括图表的目标资源、指标、拆分和筛选器维度。The new alert rule will include your chart's target resource, metric, splitting, and filter dimensions. 可以使用警报规则创建窗格修改这些设置。You can modify these settings by using the alert rule creation pane.

若要开始,请选择“新建警报规则”。To begin, select New alert rule.

屏幕截图,显示以红色突出显示的“新建警报规则”按钮。

此时会打开警报规则创建窗格。The alert rule creation pane opens. 在窗格中,可以看到图表的指标维度。In the pane, you see the chart's metric dimensions. 窗格中的字段已预填充,这有助于你自定义规则。The fields in the pane are prepopulated to help you customize the rule.

屏幕截图,显示规则创建窗格。

有关详细信息,请参阅创建、查看和管理指标警报For more information, see Create, view, and manage metric alerts.

将指标关联到日志Correlate metrics to logs

为了帮助客户对其指标图表中异常情况的根本原因进行诊断,我们创建了“深入查看日志”。To help customer diagnose the root cause of anomalies in their metrics chart, we created Drill into Logs. 利用“深入查看日志”,客户可以将其指标图表中的峰值与日志和查询关联起来。Drill into Logs allows customers to correlate spikes in their metrics chart to logs and queries.

在深入探讨这个体验之前,需要先介绍提供的不同类型的日志和查询。Before we dive into the experience, we want to first introduce the different types of logs and queries provided.

术语Term 定义Definition
活动日志Activity logs 了解从外部(管理平台) 对订阅中的每个 Azure 资源执行的操作,以及对服务运行状况事件进行的更新。Provides insight into the operations on each Azure resource in the subscription from the outside (the management plane) in addition to updates on Service Health events. 通过活动日志,可确定订阅中资源上进行的任何写入操作(PUT、POST、DELETE)的“什么操作、谁操作和操作时间”等信息。Use the Activity Log, to determine the what, who, and when for any write operations (PUT, POST, DELETE) taken on the resources in your subscription. 每个 Azure 订阅都有一个活动日志。There is a single Activity log for each Azure subscription.
诊断日志Diagnostic log 深入了解在 Azure 资源(数据平面)内执行的操作,例如,从 Key Vault 获取机密,或向数据库发出请求。Provide insight into operations that were performed within an Azure resource (the data plane), for example getting a secret from a Key Vault or making a request to a database. 资源日志的内容因 Azure 服务和资源类型而异。The content of resource logs varies by the Azure service and resource type. 注意:必须由服务提供并由客户启用Note: Must be provided by service and enabled by customer
建议的日志Recommended log 基于方案的查询,客户可利用这些查询来调查其指标资源管理器中的异常情况。Scenario-based queries that customer can leverage to investigate anomalies in their metrics explorer.

目前,“深入查看日志”可用于特选的资源提供程序。Currently, Drill into Logs are available for select resource providers. 具有完整“深入查看日志”体验的资源提供程序为:The resource providers that have the complete Drill into Logs experience are:

  • Application InsightsApplication Insights
  • 自动缩放Autoscale
  • 应用服务App Services
  • 存储Storage

下面是 Application Insights 资源提供程序的示例体验。Below is a sample experiences for the Application Insights resource provider.

App Insights“指标”边栏选项卡中失败的请求的峰值

若要诊断失败的请求的峰值,请单击“深入查看日志”。To diagnose the spike in failed requests, click on "Drill into Logs".

“深入查看日志”下拉列表的屏幕截图

单击“失败”选项就会出现“自定义故障”边栏选项卡,其中提供了失败的操作、数量最多的异常类型和依赖项。By clicking on the failure option, you will be led to a custom failure blade that provides you with the failed operation operations, top exceptions types, and dependencies.

App Insights“失败”边栏选项卡的屏幕截图

“深入查看日志”的常见问题Common problems with Drill into Logs

  • 日志和查询已禁用 - 若要查看建议的日志和查询,必须将诊断日志路由到 Log Analytics。Log and queries are disabled - To view recommended logs and queries, you must route your diagnostic logs to Log Analytics. 请阅读此文档以了解如何执行此操作。Read this document to learn how to do this.
  • 只提供活动日志 -“深入查看日志”功能只适用于特选的资源提供程序。Activity logs are only provided - The Drill into Logs feature is only available for select resource providers. 在默认情况下提供的是活动日志。By default, activity logs are provided.

故障排除Troubleshooting

如果在图表上看不到任何数据,请查看以下故障排除信息:If you don't see any data on your chart, review the following troubleshooting information:

  • 筛选器应用到窗格中的所有图表。Filters apply to all of the charts on the pane. 将焦点放在某个图表上时,请确保未在其他图表上设置会排除所有数据的筛选器。While you focus on a chart, make sure that you don't set a filter that excludes all the data on another chart.

  • 若要在不同的图表上设置不同的筛选器,请在不同的边栏选项卡中创建图表。To set different filters on different charts, create the charts in different blades. 然后将图表保存为独立的收藏项。Then save the charts as separate favorites. 可以根据需要将这些图表固定到仪表板,以便集中查看。If you want, you can pin the charts to the dashboard so you can see them together.

  • 如果根据指标未定义的属性对图表进行细分,则图表不显示任何内容。If you segment a chart by a property that the metric doesn't define, the chart displays no content. 请尝试清除分段(拆分),或选择其他属性。Try clearing the segmentation (splitting), or choose a different property.

后续步骤Next steps

若要使用指标创建可操作的仪表板,请参阅创建自定义 KPI 仪表板To create actionable dashboards by using metrics, see Creating custom KPI dashboards.