Azure Monitor 指标概述Azure Monitor Metrics overview

Azure Monitor 指标是 Azure Monitor 的一项功能,它将受监视的资源中的数值数据收集到时序数据库。Azure Monitor Metrics is a feature of Azure Monitor that collects numeric data from monitored resources into a time series database. 指标是定期收集的数值,用于描述系统在某一特定时间的某些情况。Metrics are numerical values that are collected at regular intervals and describe some aspect of a system at a particular time. Azure Monitor 中的指标是轻型数据,能够支持准实时方案,这让其在发出警报和快速检测问题方面特别有用。Metrics in Azure Monitor are lightweight and capable of supporting near real-time scenarios making them particularly useful for alerting and fast detection of issues. 您可以使用指标资源管理器以交互方式分析它们,在值超过阈值时主动收到通知警报,或者在工作簿或仪表板中将其可视化。You can analyze them interactively with metrics explorer, be proactively notified with an alert when a value crosses a threshold, or visualize them in a workbook or dashboard.


Azure Monitor 指标是支持 Azure Monitor 的数据平台的一半。Azure Monitor Metrics is one half of the data platform supporting Azure Monitor. 另一半是 Azure Monitor 日志它收集和组织日志和性能数据,并允许使用丰富的查询语言进行分析。The other is Azure Monitor Logs which collects and organizes log and performance data and allows it to be analyzed with a rich query language. 指标比 Azure Monitor 日志中的数据更为轻量,并且能够支持准实时方案,因此特别适用于对问题发出警报并快速进行检测。Metrics are more lightweight than data in Azure Monitor Logs and capable of supporting near real-time scenarios making them particularly useful for alerting and fast detection of issues. 不过,指标只能将数值数据存储在特定的结构中,而日志可以存储各种不同的数据类型,每个数据类型都有自己的结构。Metrics though can only store numeric data in a particular structure, while Logs can store a variety of different data types each with their own structure. 还可使用日志查询对日志数据执行复杂的分析,只是无法分析指标数据。You can also perform complex analysis on Logs data using log queries which cannot be used for analysis of Metrics data.

Azure Monitor 指标有何用途?What can you do with Azure Monitor Metrics?

下表列出了在 Azure Monitor 中指标的不同使用方式。The following table lists the different ways that you can use Metrics in Azure Monitor.

分析Analyze 使用指标资源管理器分析图表上收集的指标,并比较来自不同资源的指标。Use metrics explorer to analyze collected metrics on a chart and compare metrics from different resources.
AlertAlert 配置指标警报规则,以在指标值超过阈值时发送通知或执行自动化操作Configure a metric alert rule that sends a notification or takes automated action when the metric value crosses a threshold.
可视化Visualize 将指标资源管理器中的图表固定到 Azure 仪表板Pin a chart from metrics explorer to an Azure dashboard.
创建工作簿,以与交互式报表中的多组数据合并。将查询结果导出到 Grafana,以利用它的仪表板,并与其他数据源合并。Create a workbook to combine with multiple sets of data in an interactive report.Export the results of a query to Grafana to leverage its dashboarding and combine with other data sources.
自动化Automate 使用自动缩放并根据超过阈值的指标值来增加或减少资源。Use Autoscale to increase or decrease resources based on a metric value crossing a threshold.
检索Retrieve 使用 PowerShell cmdlet 通过命令行来访问指标值Access metric values from a command line using PowerShell cmdlets
使用 REST API 通过自定义应用来访问指标值。Access metric values from custom application using REST API.
使用 CLI 通过命令行来访问指标值。Access metric values from a command line using CLI.
导出Export 将指标路由到日志,以将 Azure Monitor 指标中的数据与 Azure Monitor 日志中的数据一起进行分析,并将指标值存储超过 93 天。Route Metrics to Logs to analyze data in Azure Monitor Metrics together with data in Azure Monitor Logs and to store metric values for longer than 93 days.
将指标流式传输到事件中心,以路由到外部系统。Stream Metrics to an Event Hub to route them to external systems.
存档Archive 出于符合性、审核或脱机报告目的,对资源的性能或运行状况历史记录进行 存档Archive the performance or health history of your resource for compliance, auditing, or offline reporting purposes.


数据收集Data collection

Azure Monitor 从三个基本源收集指标。There are three fundamental sources of metrics collected by Azure Monitor. 只要在 Azure Monitor 指标数据库中收集了这些指标,就可以一起评估它们,而不管它们的数据源是什么。Once these metrics are collected in the Azure Monitor metric database, they can be evaluated together regardless of their source.

Azure 资源Azure resources. 平台指标由 Azure 资源创建,可用于洞察这些资源的运行状况和性能。Platform metrics are created by Azure resources and give you visibility into their health and performance. 每种资源创建一组非重复性指标,无需进行任何配置。Each type of resource creates a distinct set of metrics without any configuration required. 平台指标每分钟从 Azure 资源中收集一次,除非在指标的定义中另有规定。Platform metrics are collected from Azure resources at one-minute frequency unless specified otherwise in the metric's definition.

应用程序Applications. 指标由 Application Insights 为受监视的应用程序创建,可帮助检测性能问题,以及跟踪应用程序的用法趋势。Metrics are created by Application Insights for your monitored applications and help you detect performance issues and track trends in how your application is being used. 此类指标包括“服务器响应时间”和“浏览器异常”等值。 This includes such values as Server response time and Browser exceptions.

虚拟机代理Virtual machine agents. 指标从虚拟机的来宾操作系统收集。Metrics are collected from the guest operating system of a virtual machine. 使用 Windows 诊断扩展 (WAD) 为 Windows 虚拟机启用来宾 OS 指标,并使用 InfluxData Telegraf 代理为 Linux 虚拟机启用来宾 OS 指标。Enable guest OS metrics for Windows virtual machines with Windows Diagnostic Extension (WAD) and for Linux virtual machines with InfluxData Telegraf Agent.

指标资源管理器Metrics explorer

使用指标资源管理器以交互方式分析指标数据库中的数据,并绘制随时间变化的多个指标的值图表。Use Metrics Explorer to interactively analyze the data in your metric database and chart the values of multiple metrics over time. 可以将图表固定到仪表板,以便使用其他可视化效果来查看它们。You can pin the charts to a dashboard to view them with other visualizations. 还可以使用 Azure 监视 REST API 检索指标。You can also retrieve metrics by using the Azure monitoring REST API.


数据结构Data structure

Azure Monitor 指标收集的数据存储在更适合分析带有时间戳的数据的时序数据库中。Data collected by Azure Monitor Metrics is stored in a time-series database which is optimized for analyzing time-stamped data. 每组指标值都是具有以下属性的时序:Each set of metric values is a time series with the following properties:

  • 值的收集时间The time the value was collected
  • 与值关联的资源The resource the value is associated with
  • 充当指标类别的命名空间A namespace that acts like a category for the metric
  • 指标名称A metric name
  • 值本身The value itself
  • 一些指标可能会有多个维度,如多维指标中所述。Some metrics may have multiple dimensions as described in Multi-dimensional metrics. 自定义指标最多可以包含 10 个维度。Custom metrics can have up to 10 dimensions.

多维指标Multi-dimensional metrics

指标数据面临的一大挑战是,通常只有有限的信息来为收集的值提供上下文。One of the challenges to metric data is that it often has limited information to provide context for collected values. Azure Monitor 通过多维指标解决了这一挑战。Azure Monitor addresses this challenge with multi-dimensional metrics. 指标维度是携带附加数据来描述指标值的名称/值对。Dimensions of a metric are name-value pairs that carry additional data to describe the metric value. 例如,指标“可用磁盘空间”可能有名为“驱动器”且值为“C:”和“D:”的维度,此维度可便于查看所有驱动器的可用磁盘空间,也可便于单独查看每个驱动器的可用磁盘空间。For example, a metric Available disk space could have a dimension called Drive with values C:, D:, which would allow viewing either available disk space across all drives or for each drive individually.

以下示例演示了名为“网络吞吐量”的假设指标的两个数据集。The example below illustrates two datasets for a hypothetical metric called Network Throughput. 第一个数据集不包含维度。The first dataset has no dimensions. 第二个数据集使用两个维度(IP 地址方向)显示值:The second dataset shows the values with two dimensions, IP Address and Direction:

网络吞吐量Network Throughput

时间戳Timestamp 指标值Metric Value
8/9/2017 8:148/9/2017 8:14 1,331.8 Kbps1,331.8 Kbps
8/9/2017 8:158/9/2017 8:15 1,141.4 Kbps1,141.4 Kbps
8/9/2017 8:168/9/2017 8:16 1,110.2 Kbps1,110.2 Kbps

上述不包含维度的指标只能够回答类似“在某个给定时间我的网络吞吐量是多少?”的基本问题This non-dimensional metric can only answer a basic question like "what was my network throughput at a given time?”

网络吞吐量 + 两个维度(“IP 地址”和“方向”)Network Throughput + two dimensions ("IP" and "Direction")

时间戳Timestamp “IP”维度Dimension "IP" “方向”维度Dimension "Direction" 指标值Metric Value
8/9/2017 8:148/9/2017 8:14 IP=""IP="" Direction="Send"Direction="Send" 646.5 Kbps646.5 Kbps
8/9/2017 8:148/9/2017 8:14 IP=""IP="" Direction="Receive"Direction="Receive" 420.1 Kbps420.1 Kbps
8/9/2017 8:148/9/2017 8:14 IP=""IP="" Direction="Send"Direction="Send" 150.0 Kbps150.0 Kbps
8/9/2017 8:148/9/2017 8:14 IP=""IP="" Direction="Receive"Direction="Receive" 115.2 Kbps115.2 Kbps
8/9/2017 8:158/9/2017 8:15 IP=""IP="" Direction="Send"Direction="Send" 515.2 Kbps515.2 Kbps
8/9/2017 8:158/9/2017 8:15 IP=""IP="" Direction="Receive"Direction="Receive" 371.1 Kbps371.1 Kbps
8/9/2017 8:158/9/2017 8:15 IP=""IP="" Direction="Send"Direction="Send" 155.0 Kbps155.0 Kbps
8/9/2017 8:158/9/2017 8:15 IP=""IP="" Direction="Receive"Direction="Receive" 100.1 Kbps100.1 Kbps

此指标可以回答类似“每个 IP 地址的网络吞吐量是多少?”,以及“相对于收到的数据,发送的数据有多少?”的问题This metric can answer questions such as "what was the network throughput for each IP address?", and "how much data was sent versus received?" 与不包含维度的指标相比,多维指标具有更多分析值和诊断值。Multi-dimensional metrics carry additional analytical and diagnostic value compared to non-dimensional metrics.

指标保留期Retention of Metrics

对于 Azure 中的大多数资源,指标的存储时间为 93 天。For most resources in Azure, metrics are stored for 93 days. 有一些例外情况:There are some exceptions:

来宾 OS 指标Guest OS metrics

  • 经典来宾 OS 指标。Classic guest OS metrics. 这些性能计数器由 Windows 诊断扩展 (WAD)Linux 诊断扩展 (LAD) 收集,并路由到 Azure 存储帐户。These are performance counters collected by the Windows Diagnostic Extension (WAD) or the Linux Diagnostic Extension (LAD) and routed to an Azure storage account. 保证这些指标的保留期至少为 14 天,但不会将实际的到期日期写入存储帐户。Retention for these metrics is guaranteed to be at least 14 days, though no actual expiration date is written to the storage account. 出于性能原因,门户会根据卷限制显示的数据量。For performance reasons, the portal limits how much data it displays based on volume. 因此,如果写入的数据量不太大,则门户检索到的实际天数可能会超过 14 天。Therefore, the actual number of days retrieved by the portal can be longer than 14 days if the volume of data being written is not very large.
  • 发送到 Azure Monitor 指标的来宾 OS 指标。Guest OS metrics sent to Azure Monitor Metrics. 这些性能计数器由 Windows 诊断扩展 (WAD) 收集,并发送到 Azure Monitor 数据接收器,或通过 Linux 计算机上的 InfluxData Telegraf 代理收集。These are performance counters collected by the Windows Diagnostic Extension (WAD) and sent to the Azure Monitor data sink, or via the InfluxData Telegraf Agent on Linux machines. 这些指标的保留期为 93 天。Retention for these metrics is 93 days.
  • Log Analytics 代理收集的来宾 OS 指标。Guest OS metrics collected by Log Analytics agent. 这些性能计数器由 Log Analytics 代理收集,并发送到 Log Analytics 工作区。These are performance counters collected by the Log Analytics agent and sent to a Log Analytics workspace. 这些指标的保留期为 31 天,最多可延长到 2 年。Retention for these metrics is 31 days, and can be extended up to 2 years.

基于 Application Insights 日志的指标Application Insights log-based metrics.

  • 在后台,基于日志的指标转换为日志查询。Behind the scene, log-based metrics translate into log queries. 它们的保留期与基础日志中的事件的保留期一致。Their retention matches the retention of events in underlying logs. 对于 Application Insights 资源,日志的存储时间为 90 天。For Application Insights resources, logs are stored for 90 days.

后续步骤Next steps