Azure Monitor 常见问题解答Azure Monitor Frequently Asked Questions

本 Microsoft 常见问题解答文章列出了有关 Azure Monitor 的常见问题。This Microsoft FAQ is a list of commonly asked questions about Azure Monitor.

常规General

说明是 Azure Monitor?What is Azure Monitor?

Azure Monitor 是 Azure 中的一个服务,它为 Azure 中、其他云环境中或本地的应用程序和服务提供性能与可用性监视。Azure Monitor is a service in Azure that provides performance and availability monitoring for applications and services in Azure, other cloud environments, or on-premises. Azure Monitor 将多个源的数据收集到一个公用数据平台,在此平台中可以分析这些数据以了解趋势和异常情况。Azure Monitor collects data from multiple sources into a common data platform where it can be analyzed for trends and anomalies. Azure Monitor 中的丰富功能可帮助你快速识别和应对可能影响应用程序的严重问题。Rich features in Azure Monitor assist you in quickly identifying and responding to critical situations that may affect your application.

Azure Monitor、Log Analytics 和 Application Insights 有何不同之处?What's the difference between Azure Monitor, Log Analytics, and Application Insights?

2018 年 9 月,Microsoft 将 Azure Monitor、Log Analytics 和 Application Insights 整合到了单个服务中,以针对应用程序及其依赖的组件提供强有力的端到端监视功能。In September 2018, Microsoft combined Azure Monitor, Log Analytics, and Application Insights into a single service to provide powerful end-to-end monitoring of your applications and the components they rely on. Log Analytics 和 Application Insights 中的功能未有变化,不过,某些功能以采用 Azure Monitor 这一名称的方式重新推出,以便更好地反映其新的应用范围。Features in Log Analytics and Application Insights have not changed, although some features have been rebranded to Azure Monitor in order to better reflect their new scope. Log Analytics 的日志数据引擎和查询语言现在称为 Azure Monitor 日志。The log data engine and query language of Log Analytics is now referred to as Azure Monitor Logs. 请参阅 Azure Monitor 术语更新See Azure Monitor terminology updates.

Azure Monitor 如何收费?What does Azure Monitor cost?

自动启用的 Azure Monitor 功能(例如指标和活动日志的收集)是免费提供的。Features of Azure Monitor that are automatically enabled such as collection of metrics and activity logs are provided at no cost. 日志查询和警报等其他功能会产生相关的费用。There is a cost associated with other features such as log queries and alerting. 有关详细定价信息,请参阅 Azure Monitor 定价页See the Azure Monitor pricing page for detailed pricing information.

如何启用 Azure Monitor?How do I enable Azure Monitor?

在创建新的 Azure 订阅时即会启用 Azure Monitor,然后会自动收集活动日志和平台指标Azure Monitor is enabled the moment that you create a new Azure subscription, and Activity log and platform metrics are automatically collected. 创建诊断设置可以收集有关 Azure 资源操作的更多详细信息,添加监视解决方案见解可以针对收集的特定服务数据提供额外的分析。Create diagnostic settings to collect more detailed information about the operation of your Azure resources, and add monitoring solutions and insights to provide additional analysis on collected data for particular services.

如何访问 Azure Monitor?How do I access Azure Monitor?

可以通过 Azure 门户中的“监视”菜单访问所有 Azure Monitor 功能和数据。Access all Azure Monitor features and data from the Monitor menu in the Azure portal. 可以通过不同 Azure 服务的“监视”菜单部分访问相同的工具,在这种情况下,会按照特定的资源筛选数据。The Monitoring section of the menu for different Azure services provides access to the same tools with data filtered to a particular resource. 对于多种使用 CLI、PowerShell 和 REST API 的方案,Azure Monitor 数据也是可访问的。Azure Monitor data is also accessible for a variety of scenarios using CLI, PowerShell, and a REST API.

Azure Monitor 是否有本地版本?Is there an on-premises version of Azure Monitor?

否。No. Azure Monitor 是可以处理和存储大量数据的可缩放云服务,不过,Azure Monitor 还可以监视本地和其他云中的资源。Azure Monitor is a scalable cloud service that processes and stores large amounts of data, although Azure Monitor can monitor resources that are on-premises and in other clouds.

Azure Monitor 是否可以监视本地资源?Can Azure Monitor monitor on-premises resources?

是的,除了从 Azure 资源收集监视数据以外,Azure Monitor 还可以从其他云中和本地的虚拟机与应用程序收集数据。Yes, in addition to collecting monitoring data from Azure resources, Azure Monitor can collect data from virtual machines and applications in other clouds and on-premises. 请参阅 Azure Monitor 的监视数据源See Sources of monitoring data for Azure Monitor.

Azure Monitor 使用哪些 IP 地址?What IP addresses does Azure Monitor use?

有关代理和其他外部资源访问 Azure Monitor 所需的 IP 地址与端口的列表,请参阅 Application Insights 和 Log Analytics 使用的 IP 地址See IP addresses used by Application Insights and Log Analytics for a listing of the IP addresses and ports required for agents and other external resources to access Azure Monitor.

监视数据Monitoring data

Azure Monitor 从何处获取其数据?Where does Azure Monitor get its data?

Azure Monitor 从各种源(包括来自 Azure 平台和资源、自定义应用程序以及虚拟机上运行的代理的日志和指标)收集数据。Azure Monitor collects data from a variety of sources including logs and metrics from Azure platform and resources, custom applications, and agents running on virtual machines. 其他服务(例如 Azure 安全中心和网络观察程序)将数据收集到 Log Analytics 工作区中,以便可以结合 Azure Monitor 数据一起进行分析。Other services such as Azure Security Center and Network Watcher collect data into a Log Analytics workspace so it can be analyzed with Azure Monitor data. 还可以使用适用于日志或指标的 REST API 将自定义数据发送到 Azure Monitor。You can also send custom data to Azure Monitor using the REST API for logs or metrics. 请参阅 Azure Monitor 的监视数据源See Sources of monitoring data for Azure Monitor.

Azure Monitor 收集哪些数据?What data is collected by Azure Monitor?

Azure Monitor 将各种源的数据收集到日志指标中。Azure Monitor collects data from a variety of sources into logs or metrics. 每种数据类型具有自身的相对优势,每种类型支持 Azure Monitor 中特定的一组功能。Each type of data has its own relative advantages, and each supports a particular set of features in Azure Monitor. 每个 Azure 订阅有一个指标数据库,同时,你可以根据需要创建多个 Log Analytics 工作区来收集日志。There is a single metrics database for each Azure subscription, while you can create multiple Log Analytics workspaces to collect logs depending on your requirements. 请参阅 Azure Monitor 数据平台See Azure Monitor data platform.

在 Azure Monitor 中可以收集的数据量是否有上限?Is there a maximum amount of data that I can collect in Azure Monitor?

可收集的指标数据量没有限制,但这些数据最多只能存储 93 天。There is no limit to the amount of metric data you can collect, but this data is stored for a maximum of 93 days. 请参阅指标的保留期See Retention of Metrics. 可收集的日志数据量没有限制,但你为 Log Analytics 工作区选择的定价层可能会影响你可以收集的数据量。There is no limit on the amount of log data that you can collect, but it may be affected by the pricing tier you choose for the Log Analytics workspace. 请参阅定价详细信息See pricing details.

如何访问 Azure Monitor 收集的数据?How do I access data collected by Azure Monitor?

见解和解决方案提供自定义的体验用于处理 Azure Monitor 中存储的数据。Insights and solutions provide a custom experience for working with data stored in Azure Monitor. 可以使用以 Kusto 查询语言 (KQL) 编写的日志查询直接处理日志数据。You can work directly with log data using a log query written in Kusto Query Language (KQL). 在 Azure 门户中,可以编写和运行查询,并使用 Log Analytics 以交互方式分析数据。In the Azure portal, you can write and run queries and interactively analyze data using Log Analytics. 在 Azure 门户中使用指标资源管理器分析指标。Analyze metrics in the Azure portal with the Metrics Explorer. 请参阅在 Azure Monitor 中分析日志数据Azure 指标资源管理器入门See Analyze log data in Azure Monitor and Getting started with Azure Metrics Explorer.

解决方案和见解Solutions and insights

Azure Monitor 中的见解是什么?What is an insight in Azure Monitor?

见解针对特定的 Azure 服务提供自定义的监视体验。Insights provide a customized monitoring experience for particular Azure services. 它们使用的指标和日志与 Azure Monitor 中的其他功能相同,但可以收集更多数据,并在 Azure 门户中提供独特的体验。They use the same metrics and logs as other features in Azure Monitor but may collect additional data and provide a unique experience in the Azure portal. 请参阅 Azure Monitor 中的见解See Insights in Azure Monitor.

若要在 Azure 门户中查看见解,请查看“监视”菜单的“见解”部分,或查看服务菜单的“监视”部分。 To view insights in the Azure portal, see the Insights section of the Monitor menu or the Monitoring section of the service's menu.

Azure Monitor 中的解决方案是什么?What is a solution in Azure Monitor?

监视解决方案是打包的逻辑集,用于根据 Azure Monitor 功能监视特定的应用程序或服务。Monitoring solutions are packaged sets of logic for monitoring a particular application or service based on Azure Monitor features. 它们在 Azure Monitor 中收集日志数据,并使用 Azure 门户中的常用体验为它们的分析提供日志查询和视图。They collect log data in Azure Monitor and provide log queries and views for their analysis using a common experience in the Azure portal. 请参阅 Azure Monitor 中的监视解决方案See Monitoring solutions in Azure Monitor.

若要在 Azure 门户中查看解决方案,请在“监视”菜单的“见解”部分单击“更多”。 To view solutions in the Azure portal, click More in the Insights section of the Monitor menu. 单击“添加”可将更多解决方案添加到工作区中。Click Add to add additional solutions to the workspace.

日志Logs

Azure Monitor 日志与 Azure 数据资源管理器有何不同之处?What's the difference between Azure Monitor Logs and Azure Data Explorer?

Azure 数据资源管理器是一项快速且高度可缩放的数据探索服务,适用于日志和遥测数据。Azure Data Explorer is a fast and highly scalable data exploration service for log and telemetry data. Azure Monitor 日志构建在 Azure 数据资源管理器的基础之上,两者使用相同的 Kusto 查询语言 (KQL),但存在一些细微的差别。Azure Monitor Logs is built on top of Azure Data Explorer and uses the same Kusto Query Language (KQL) with some minor differences. 请参阅 Azure Monitor 日志查询语言差异See Azure Monitor log query language differences.

如何检索日志数据?How do I retrieve log data?

可以使用以 Kusto 查询语言 (KQL) 编写的日志查询从 Log Analytics 工作区检索所有数据。All data is retrieved from a Log Analytics workspace using a log query written using Kusto Query Language (KQL). 你可以编写自己的查询,或使用包含针对特定应用程序或服务的日志查询的解决方案与见解。You can write your own queries or use solutions and insights that include log queries for a particular application or service. 请参阅 Azure Monitor 中的日志查询概述See Overview of log queries in Azure Monitor.

什么是 Log Analytics 工作区?What is a Log Analytics workspace?

Azure Monitor 收集的所有日志数据存储在 Log Analytics 工作区中。All log data collected by Azure Monitor is stored in a Log Analytics workspace. 工作区本质上是从各种源将日志数据收集到的容器。A workspace is essentially a container where log data is collected from a variety of sources. 你可能会对所有监视数据使用单个 Log Analytics 工作区,或者可能有使用多个工作区的需求。You may have a single Log Analytics workspace for all your monitoring data or may have requirements for multiple workspaces. 请参阅设计 Azure Monitor 日志部署See Designing your Azure Monitor Logs deployment.

是否可将现有的 Log Analytics 工作区移到另一个 Azure 订阅?Can you move an existing Log Analytics workspace to another Azure subscription?

可以在资源组或订阅之间移动工作区,但不能跨区域移动。You can move a workspace between resource groups or subscriptions but not to a different region.

Log Analytics 中为何不显示“查询资源管理器”和“保存”按钮?Why can't I see Query Explorer and Save buttons in Log Analytics?

查询范围设置为特定的资源时,不会显示“查询资源管理器”、“保存”和“新建警报规则”按钮。 Query Explorer, Save and New alert rule buttons are not available when the query scope is set to a specific resource. 若要创建警报,或者要保存或加载查询,Log Analytics 的范围必须限定于某个工作区。To create alerts, save or load a query, Log Analytics must be scoped to a workspace. 若要在工作区上下文中打开 Log Analytics,请从“Azure Monitor”菜单中选择“日志”。 To open Log Analytics in workspace context, select Logs from the Azure Monitor menu. 选择的是上次使用的工作区,但可以选择任何其他的工作区。The last used workspace is selected, but you can select any other workspace. 请参阅 Azure Monitor Log Analytics 中的日志查询范围和时间范围See Log query scope and time range in Azure Monitor Log Analytics

为什么从 VM 钻取进去后,我会在日志中发现以下错误:从 VM 打开 Log Analytics 时,为何显示“请为此订阅注册资源提供程序 'Microsoft.Insights' 以启用此查询”?Why am I getting the error: "Register resource provider 'Microsoft.Insights' for this subscription to enable this query" when opening Log Analytics from a VM?

许多资源提供程序会自动注册,但某些资源提供程序可能需要手动注册。Many resource providers are automatically registered, but you may need to manually register some resource providers. 注册的作用域始终是订阅。The scope for registration is always the subscription. 有关详细信息,请参阅资源提供程序和类型See Resource providers and types for more information.

从 VM 打开 Log Analytics 时,为何出现“无访问权限”错误消息?Why am I am getting no access error message when opening Log Analytics from a VM?

若要查看 VM 日志,需获得存储 VM 日志的工作区的读取权限。To view VM Logs, you need to be granted with read permission to the workspaces that stores the VM logs. 在这些示例中,管理员必须在 Azure 中为你授予相关权限。In these cases, your administrator must grant you with to permissions in Azure.

警报Alerts

Azure Monitor 中的警报是什么?What is an alert in Azure Monitor?

在监视数据中发现重要情况时,警报会以主动的方式通知你。Alerts proactively notify you when important conditions are found in your monitoring data. 有了警报,你就可以在系统的用户注意到问题之前确定和解决这些问题。They allow you to identify and address issues before the users of your system notice them. 有多种类型的警报:There are multiple kinds of alerts:

  • 指标 - 指标值超过阈值。Metric - Metric value exceeds a threshold.
  • 日志查询 - 日志查询的结果与定义的条件相匹配。Log query - Results of a log query match defined criteria.
  • 活动日志 - 活动日志事件与定义的条件相匹配。Activity log - Activity log event matches defined criteria.
  • Web 测试 - 可用性测试的结果与定义的条件相匹配。Web test - Results of availability test match defined criteria.

请查看 Azure 中的警报概述See Overview of alerts in Azure.

什么是操作组?What is an action group?

操作组是可由警报触发的通知和操作的集合。An action group is a collection of notifications and actions that can be triggered by an alert. 多个警报可以使用单个操作组,使你能够利用通用的通知和操作集。Multiple alerts can use a single action group allowing you to leverage common sets of notifications and actions. 请参阅在 Azure 门户中创建和管理器操作组See Create and manage action groups in the Azure portal.

什么是操作规则?What is an action rule?

操作规则可让你修改与特定条件匹配的一组警报的行为。An action rule allows you to modify the behavior of a set of alerts that match a certain criteria. 这样,你便可以在维护时段履行诸如禁用警报操作之类的要求。This allows you to to perform such requirements as disable alert actions during a maintenance window. 还可以将操作组应用到一组警报,而不是将其直接应用到警报规则。You can also apply an action group to a set of alerts rather than applying them directly to the alert rules. 请参阅操作规则See Action rules.

代理Agents

Azure Monitor 是否需要代理?Does Azure Monitor require an agent?

只有在从操作系统以及虚拟机中的工作负荷收集数据时才需要代理。An agent is only required to collect data from the operating system and workloads in virtual machines. 虚拟机可以位于 Azure 中、其他云环境中或本地。The virtual machines can be located in Azure, another cloud environment, or on-premises. 请参阅 Azure Monitor 代理概述See Overview of the Azure Monitor agents.

各个 Azure Monitor 代理有何不同之处?What's the difference between the Azure Monitor agents?

Azure 诊断扩展适用于 Azure 虚拟机,它将数据收集到 Azure Monitor 指标、Azure 存储和 Azure 事件中心。Azure Diagnostic extension is for Azure virtual machines and collects data to Azure Monitor Metrics, Azure Storage, and Azure Event Hubs. Log Analytics 代理适用于 Azure 中、其他云环境中或本地的虚拟机,它将数据收集到 Azure Monitor 日志。The Log Analytics agent is for virtual machines in Azure, another cloud environment, or on-premises and collects data to Azure Monitor Logs. 依赖项代理需要 Log Analytics 代理,以及收集的进程详细信息和依赖项。The Dependency agent requires the Log Analytics agent and collected process details and dependencies. 请参阅 Azure Monitor 代理概述See Overview of the Azure Monitor agents.

代理流量是否使用 ExpressRoute 连接?Does my agent traffic use my ExpressRoute connection?

发往 Azure Monitor 的流量使用 Microsoft 对等互连 ExpressRoute 线路。Traffic to Azure Monitor uses the Microsoft peering ExpressRoute circuit. 有关不同类型的 ExpressRoute 流量的说明,请参阅 ExpressRoute 文档See ExpressRoute documentation for a description of the different types of ExpressRoute traffic.

如何确认 Log Analytics 代理能够与 Azure Monitor 通信?How can I confirm that the Log Analytics agent is able to communicate with Azure Monitor?

在代理计算机上的控制面板中,选择“安全性和设置”>“Microsoft Monitoring Agent”。 From Control Panel on the agent computer, select Security & Settings, Microsoft Monitoring Agent . 在“Azure Log Analytics (OMS)”选项卡下,出现绿色的复选标记图标即表示代理能够与 Azure Monitor 通信。Under the Azure Log Analytics (OMS) tab, a green check mark icon confirms that the agent is able to communicate with Azure Monitor. 黄色警告图标表示代理有问题。A yellow warning icon means the agent is having issues. 一个常见原因是 Microsoft Monitoring Agent 服务已停止。One common reason is the Microsoft Monitoring Agent service has stopped. 请使用服务控制管理器重启该服务。Use service control manager to restart the service.

如何阻止 Log Analytics 代理与 Azure Monitor 通信?How do I stop the Log Analytics agent from communicating with Azure Monitor?

对于已直接连接到 Log Analytics 的代理,请打开控制面板,并选择“安全性和设置”>“Microsoft Monitoring Agent”。 For agents connected to Log Analytics directly, open the Control Panel and select Security & Settings, Microsoft Monitoring Agent. 在“Azure Log Analytics (OMS)”选项卡下,删除列出的所有工作区。Under the Azure Log Analytics (OMS) tab, remove all workspaces listed. 在 System Center Operations Manager 中,从 Log Analytics 托管的计算机列表中删除该计算机。In System Center Operations Manager, remove the computer from the Log Analytics managed computers list. Operations Manager 会更新该代理的配置以便不再向 Log Analytics 进行报告。Operations Manager updates the configuration of the agent to no longer report to Log Analytics.

每个代理发送多少数据?How much data is sent per agent?

每个代理发送的数据量取决于:The amount of data sent per agent depends on:

  • 已启用的解决方案The solutions you have enabled
  • 正在收集的日志和性能计数器的数量The number of logs and performance counters being collected
  • 日志中的数据量The volume of data in the logs

有关详细信息,请参阅通过 Azure Monitor 日志管理使用情况和成本See Manage usage and costs with Azure Monitor Logs for details.

对于能够运行 WireData 代理的计算机,可以使用以下查询了解正在发送的数据量:For computers that are able to run the WireData agent, use the following query to see how much data is being sent:

WireData
| where ProcessName == "C:\\Program Files\\Microsoft Monitoring Agent\\Agent\\MonitoringHost.exe" 
| where Direction == "Outbound" 
| summarize sum(TotalBytes) by Computer 

将数据发送到 Azure Monitor 时,Microsoft 管理代理 (MMA) 会使用多少网络带宽?How much network bandwidth is used by the Microsoft Management Agent (MMA) when sending data to Azure Monitor?

带宽是已发送数据量的一个函数。Bandwidth is a function on the amount of data sent. 数据通过网络发送时会被压缩。Data is compressed as it is sent over the network.

从 Log Analytics 代理收集数据的操作停止时,如何收到通知?How can I be notified when data collection from the Log Analytics agent stops?

当数据收集停止时,可以使用新建日志警报中所述的步骤收到通知。Use the steps described in create a new log alert to be notified when data collection stops. 对警报规则使用以下设置:Use the following settings for the alert rule:

  • 定义警报条件:将 Log Analytics 工作区指定为资源目标。Define alert condition: Specify your Log Analytics workspace as the resource target.
  • 警报条件Alert criteria
    • 信号名称自定义日志搜索Signal Name: Custom log search
    • 搜索查询Heartbeat | summarize LastCall = max(TimeGenerated) by Computer | where LastCall < ago(15m)Search query: Heartbeat | summarize LastCall = max(TimeGenerated) by Computer | where LastCall < ago(15m)
    • 警报逻辑基于 结果数,条件 大于,阈值 0Alert logic: Based on number of results, Condition Greater than, Threshold value 0
    • 评估依据期限(分钟) 30,频率(分钟) 10Evaluated based on: Period (in minutes) 30, Frequency (in minutes) 10
  • 定义警报详细信息Define alert details
    • 名称:“数据收集已停止”Name: Data collection stopped
    • 严重性警告Severity: Warning

指定现有或新的操作组,以便当日志警报与条件匹配时可以收到通知(如果检测信号丢失时间超过 15 分钟)。Specify an existing or new Action Group so that when the log alert matches criteria, you are notified if you have a heartbeat missing for more than 15 minutes.

Azure Monitor 代理的防火墙要求是什么?What are the firewall requirements for Azure Monitor agents?

有关防火墙要求的详细信息,请参阅网络防火墙要求See Network firewall requirementsfor details on firewall requirements.

可视化效果Visualizations

我为何看不到视图设计器?Why can't I see View Designer?

只有在 Log Analytics 工作区中分配有“参与者”权限或更高权限的用户才能看到视图设计器。View Designer is only available for users assigned with Contributor permissions or higher in the Log Analytics workspace.

Application InsightsApplication Insights

配置问题Configuration problems

我在设置以下内容时遇到问题:I'm having trouble setting up my:

我无法从服务器获取任何数据:I get no data from my server:

我应该部署多少 Application Insights:How many Application Insights should I deploy?:

是否可以将 Application Insights 用于...?Can I use Application Insights with ...?

是否免费?Is it free?

是的,对于实验用途。Yes, for experimental use. 在基本定价计划中,应用程序可以发送一些每月免费数据量。In the basic pricing plan, your application can send a certain allowance of data each month free of charge. 免费的限额足以满足开发和为少量用户发布应用的需求。The free allowance is large enough to cover development, and publishing an app for a small number of users. 可以设置上限,以防止所使用的数据量超出指定数据量。You can set a cap to prevent more than a specified amount of data from being processed.

较大的遥测量按 Gb 收费。Larger volumes of telemetry are charged by the Gb. 我们提供了一些有关如何限制费用的提示。We provide some tips on how to limit your charges.

企业计划对每个 Web 服务器节点每天发送的遥测进行收费。The Enterprise plan incurs a charge for each day that each web server node sends telemetry. 如果要大规模使用连续导出,此计划非常合适。It is suitable if you want to use Continuous Export on a large scale.

阅读定价计划Read the pricing plan.

它的成本是多少?How much does it cost?

  • 在 Application Insights 资源中打开“使用情况和估算成本”页面。Open the Usage and estimated costs page in an Application Insights resource. 此处提供了一个最近使用情况的图表。There's a chart of recent usage. 如果愿意,可以设置数据上限。You can set a data volume cap, if you want.
  • 打开 Azure 计费边栏选项卡查看所有资源的帐单。Open the Azure Billing blade to see your bills across all resources.

Application Insights 在我的项目中修改哪些内容?What does Application Insights modify in my project?

详细信息取决于项目类型。The details depend on the type of project. 对于 Web 应用程序:For a web application:

  • 将这些文件添加到项目:Adds these files to your project:
    • ApplicationInsights.configApplicationInsights.config
    • ai.jsai.js
  • 安装以下 NuGet 包:Installs these NuGet packages:
    • Application Insights API - 核心 APIApplication Insights API - the core API
    • 适用于 Web 应用程序 的 Application Insights API - 用于从服务器发送遥测Application Insights API for Web Applications - used to send telemetry from the server
    • 适用于 JavaScript 应用程序的 Application Insights API - 用于从客户端发送遥测Application Insights API for JavaScript Applications - used to send telemetry from the client
  • 这些包包括以下程序集:The packages include these assemblies:
    • Microsoft.ApplicationInsightsMicrosoft.ApplicationInsights
    • Microsoft.ApplicationInsights.PlatformMicrosoft.ApplicationInsights.Platform
  • 将项目插入:Inserts items into:
    • Web.configWeb.config
    • packages.configpackages.config
  • (仅限新项目 - 如果将 Application Insights 添加到现有项目,则必须手动执行此操作。)在客户端和服务器代码中插入代码片段,以使用 Application Insights 资源 ID 初始化它们。(New projects only - if you add Application Insights to an existing project, you have to do this manually.) Inserts snippets into the client and server code to initialize them with the Application Insights resource ID. 例如,在 MVC 应用中,代码插入到母版页 Views/Shared/_Layout.cshtml 中For example, in an MVC app, code is inserted into the master page Views/Shared/_Layout.cshtml

如何从较早的 SDK 版本升级?How do I upgrade from older SDK versions?

请参阅发行说明了解对应于应用程序类型的 SDK。See the release notes for the SDK appropriate to your type of application.

如何更改项目向哪个 Azure 资源发送数据?How can I change which Azure resource my project sends data to?

在解决方案资源管理器中,右键单击 ApplicationInsights.config 并选择“更新 Application Insights”。In Solution Explorer, right-click ApplicationInsights.config and choose Update Application Insights. 可在 Azure 中将数据发送到现有或新资源。You can send the data to an existing or new resource in Azure. 更新向导更改 ApplicationInsights.config 中的检测密钥,该密钥确定服务器 SDK 将数据发送到何处。The update wizard changes the instrumentation key in ApplicationInsights.config, which determines where the server SDK sends your data. 除非取消选中“更新全部”,否则它还将在网页中出现密钥的位置更改密钥。Unless you deselect "Update all," it will also change the key where it appears in your web pages.

可以在 Azure 资源管理器部署中使用 providers('Microsoft.Insights', 'components').apiVersions[0] 吗?Can I use providers('Microsoft.Insights', 'components').apiVersions[0] in my Azure Resource Manager deployments?

不建议使用此方法来填充 API 版本。We do not recommend using this method of populating the API version. 最新版本可以表示预览版本,该版本可能包含重大更改。The newest version can represent preview releases which may contain breaking changes. 即使使用较新的非预览版本,API 版本也并不总是向后兼容现有的模板,或者在某些情况下,API 版本可能不适用于所有订阅。Even with newer non-preview releases, the API versions are not always backwards compatible with existing templates, or in some cases the API version may not be available to all subscriptions.

什么是状态监视器?What is Status Monitor?

它是可以在 IIS Web 服务器中使用的桌面应用,用于帮助在 Web 应用中配置 Application Insights。A desktop app that you can use in your IIS web server to help configure Application Insights in web apps. 它不会收集遥测:不配置应用时,可以停止此监视器。It doesn't collect telemetry: you can stop it when you are not configuring an app.

了解详细信息Learn more.

Application Insights 收集哪些遥测?What telemetry is collected by Application Insights?

从服务器 Web 应用:From server web apps:

客户端网页From client web pages:

从其他源中(如果有配置):From other sources, if you configure them:

是否可以筛选或修改某些遥测?Can I filter out or modify some telemetry?

可以,可在服务器中编写:Yes, in the server you can write:

  • 用于在从应用发送属性前,对属性进行筛选并将其添加到所选遥测项的遥测处理器。Telemetry Processor to filter or add properties to selected telemetry items before they are sent from your app.
  • 用于将属性添加到所有遥测项的遥测初始化器。Telemetry Initializer to add properties to all items of telemetry.

深入了解 ASP.NETJavaLearn more for ASP.NET or Java.

如何计算市/县/区、国家/地区和其他地理位置数据?How are city, country/region, and other geo location data calculated?

使用 GeoLite2 查找 Web 客户端的 IP 地址(IPv4 或 IPv6)。We look up the IP address (IPv4 or IPv6) of the web client using GeoLite2.

  • 浏览器遥测:收集发送方的 IP 地址。Browser telemetry: We collect the sender's IP address.
  • 服务器遥测:Application Insights 模块收集客户端 IP 地址。Server telemetry: The Application Insights module collects the client IP address. 如果设置了 X-Forwarded-For,则不会进行收集。It is not collected if X-Forwarded-For is set.
  • 若要详细了解如何在 Application Insights 中收集 IP 地址和地理位置数据,请参阅此文章To learn more about how IP address and geolocation data is collected in Application Insights refer to this article.

可以配置 ClientIpHeaderTelemetryInitializer,从不同的标头获取 IP 地址。You can configure the ClientIpHeaderTelemetryInitializer to take the IP address from a different header. 例如,在某些系统中,代理、负载均衡器或 CDN 会将其移动到 X-Originating-IPIn some systems, for example, it is moved by a proxy, load balancer, or CDN to X-Originating-IP. 了解详细信息Learn more.

可以使用 Power BI 在映射中显示请求遥测。You can use Power BI to display your request telemetry on a map.

数据在门户中保留多长时间?How long is data retained in the portal? 是否安全?Is it secure?

请参阅数据保留和隐私Take a look at Data Retention and Privacy.

当服务器或设备与 Azure 断开连接时,Application Insights 的遥测数据会发生什么情况?What happens to Application Insight's telemetry when a server or device loses connection with Azure?

所有 SDK(包括 Web SDK)都提供“可靠传输”或“稳健传输”。All of our SDKs, including the web SDK, includes "reliable transport" or "robust transport". 当服务器或设备与 Azure 断开连接时,遥测数据将存储在文件系统本地(服务器 SDK)或存储在 HTML5 会话存储中 (Web SDK)。When the server or device loses connection with Azure, telemetry is stored locally on the file system (Server SDKs) or in HTML5 Session Storage (Web SDK). SDK 会定期重试发送此遥测数据,直到引入服务将此数据视为“已过时”(对于日志,为 48 小时;对于指标,为 30 分钟)。The SDK will periodically retry to send this telemetry until our ingestion service considers it "stale" (48-hours for logs, 30 minutes for metrics). 过时的遥测数据将被删除。Stale telemetry will be dropped. 在某些情况下(例如本地存储已满时),将不会重试。In some cases, such as when local storage is full, retry will not occur.

是否可能会在遥测中发送个人数据?Could personal data be sent in the telemetry?

如果代码发送了此类数据,则有可能。This is possible if your code sends such data. 如果堆栈跟踪中的变量包括个人数据,也可能发生这种情况。It can also happen if variables in stack traces include personal data. 开发团队应进行风险评估,确保妥善处理个人数据。Your development team should conduct risk assessments to ensure that personal data is properly handled. 深入了解数据保留和隐私Learn more about data retention and privacy.

所有八进制数的客户端 web 地址始终设置为 0,查找异地位置属性。All octets of the client web address are always set to 0 after the geo location attributes are looked up.

在网页源中可见我的检测密钥。My Instrumentation Key is visible in my web page source.

  • 这是监视解决方案的常见做法。This is common practice in monitoring solutions.
  • 它不能用于窃取数据。It can't be used to steal your data.
  • 但可用于倾斜数据或触发警报。It could be used to skew your data or trigger alerts.
  • 我们未曾听说有任何客户遇到了此类问题。We have not heard that any customer has had such problems.

可以:You could:

  • 将两个单独检测密钥(独立的 Application Insights 资源)分别用于客户端和服务器数据。Use two separate Instrumentation Keys (separate Application Insights resources), for client and server data. Or
  • 编写一个在服务器中运行的代理,并使 Web 客户端通过该代理发送数据。Write a proxy that runs in your server, and have the web client send data through that proxy.

如何在诊断搜索中查看 POST 数据?How do I see POST data in Diagnostic search?

我们不自动记录 POST 数据,但可以使用 TrackTrace 调用:将数据放置在消息参数中。We don't log POST data automatically, but you can use a TrackTrace call: put the data in the message parameter. 相比对字符串属性的限制,这具有更长的大小限制,尽管你无法对其进行筛选。This has a longer size limit than the limits on string properties, though you can't filter on it.

应使用单个 Application Insights 资源还是多个 Application Insights 资源?Should I use single or multiple Application Insights resources?

对单个业务系统中的所有组件或角色使用单个资源。Use a single resource for all the components or roles in a single business system. 对开发、测试和发布版本以及独立应用程序使用单独的资源。Use separate resources for development, test, and release versions, and for independent applications.

如何动态更改检测密钥?How do I dynamically change the instrumentation key?

什么是用户和会话计数?What are the User and Session counts?

  • JavaScript SDK 在 Web 客户端上设置了用于识别返回用户的用户 cookie,以及用于对活动进行分组的会话 cookie。The JavaScript SDK sets a user cookie on the web client, to identify returning users, and a session cookie to group activities.
  • 如果没有客户端脚本,可以在服务器设置 cookieIf there is no client-side script, you can set cookies at the server.
  • 如果一个真实的用户在不同的浏览器中使用站点,或者使用私密/隐身浏览,或使用不同的计算机,则会进行多次计数。If one real user uses your site in different browsers, or using in-private/incognito browsing, or different machines, then they will be counted more than once.
  • 若要识别跨计算机和浏览器登录的用户,请添加对 setAuthenticatedUserContext() 的调用。To identify a logged-in user across machines and browsers, add a call to setAuthenticatedUserContext().

我是否已在 Application Insights 中启用所有内容?Have I enabled everything in Application Insights?

应看到What you should see 如何获取How to get it 为何需要它Why you want it
可用性图表Availability charts Web 测试Web tests 知道 Web 应用已启动Know your web app is up
服务器应用性能:响应时间、...Server app perf: response times, ... 将 Application Insights 添加到项目在服务器上安装 AI 状态监视器(或编写自己的代码以跟踪依赖项Add Application Insights to your project or Install AI Status Monitor on server (or write your own code to track dependencies) 检测性能问题Detect perf issues
依赖项遥测Dependency telemetry 在服务器上安装 AI 状态监视器Install AI Status Monitor on server 诊断数据库或其他外部组件问题Diagnose issues with databases or other external components
获取异常的堆栈跟踪Get stack traces from exceptions 在代码中插入 TrackException 调用(但有些会自动报告)Insert TrackException calls in your code (but some are reported automatically) 检测和诊断异常Detect and diagnose exceptions
搜索日志跟踪Search log traces 添加日志记录适配器Add a logging adapter 诊断异常、性能问题Diagnose exceptions, perf issues
客户端使用基础知识:页面视图、会话、...Client usage basics: page views, sessions, ... 网页中的 JavaScript 初始值设定项JavaScript initializer in web pages 使用情况分析Usage analytics
客户端自定义指标Client custom metrics 在网页中跟踪调用Tracking calls in web pages 增强用户体验Enhance user experience
服务器自定义指标Server custom metrics 在服务器中跟踪调用Tracking calls in server 商业智能Business intelligence

为什么搜索图表和指标图表中的计数不一致?Why are the counts in Search and Metrics charts unequal?

采样减少了实际从应发送到门户的遥测项(请求、自定义事件等)数量。Sampling reduces the number of telemetry items (requests, custom events, and so on) that are actually sent from your app to the portal. 在搜索中,看到的是实际接收到的项数。In Search, you see the number of items actually received. 在显示事件计数的指标图表中,看到的是发生的原始事件数。In metric charts that display a count of events, you see the number of original events that occurred.

传输的每个项都携带一个 itemCount 属性,此属性显示该项表示的原始事件数量。Each item that is transmitted carries an itemCount property that shows how many original events that item represents. 若要观察操作中的采样,可以在分析中运行此查询:To observe sampling in operation, you can run this query in Analytics:

    requests | summarize original_events = sum(itemCount), transmitted_events = count()

自动化Automation

配置 Application InsightsConfiguring Application Insights

可以使用 Azure 资源监视器编写 PowerShell 脚本You can write PowerShell scripts using Azure Resource Monitor to:

  • 创建并更新 Application Insights 资源。Create and update Application Insights resources.
  • 设置定价计划。Set the pricing plan.
  • 获取检测密钥。Get the instrumentation key.
  • 添加指标警报。Add a metric alert.
  • 添加可用性测试。Add an availability test.

无法设置指标资源管理器报表,或设置连续导出。You can't set up a Metric Explorer report or set up continuous export.

查询遥测Querying the telemetry

使用 REST API 运行 Analytics 查询。Use the REST API to run Analytics queries.

如何设置事件警报?How can I set an alert on an event?

Azure 警报仅出现在指标上。Azure alerts are only on metrics. 创建一个每当事件发生时都跨越值阈值的自定义指标。Create a custom metric that crosses a value threshold whenever your event occurs. 然后在该指标上设置警报。Then set an alert on the metric. 指标在任一方向超过阈值时,你都会收到通知;无论初始值高低,你都不会在首次超过阈值之前收到通知;总是会有几分钟的延迟。You'll get a notification whenever the metric crosses the threshold in either direction; you won't get a notification until the first crossing, no matter whether the initial value is high or low; there is always a latency of a few minutes.

Azure Web 应用和 Application Insights 之间是否有数据传输费用?Are there data transfer charges between an Azure web app and Application Insights?

  • 如果 Azure Web 应用托管在具有 Application Insights 集合终结点的数据中心内,则不收取费用。If your Azure web app is hosted in a data center where there is an Application Insights collection endpoint, there is no charge.
  • 如果主机数据中心没有集合终结点,那么应用的遥测会产生 Azure 传出费用If there is no collection endpoint in your host data center, then your app's telemetry will incur Azure outgoing charges.

这与 Application Insights 资源的托管位置无关。This doesn't depend on where your Application Insights resource is hosted. 它只取决于终结点的分布情况。It just depends on the distribution of our endpoints.

是否可以将遥测数据发送到 Application Insights 门户?Can I send telemetry to the Application Insights portal?

建议使用我们的 SDK 并使用 SDK APIWe recommend you use our SDKs and use the SDK API. 为各种平台提供了相应的 SDK 变体。There are variants of the SDK for various platforms. 这些 SDK 可处理缓冲、压缩、限制以及重试等。These SDKs handle buffering, compression, throttling, retries, and so on. 但是,引入架构终结点协议是公共的。However, the ingestion schema and endpoint protocol are public.

是否可以监视 Intranet Web 服务器?Can I monitor an intranet web server?

可以,但你需要通过防火墙例外或代理重定向来允许流量到我们的服务。Yes, but you will need to allow traffic to our services by either firewall exceptions or proxy redirects.

  • QuickPulse https://rt.services.visualstudio.com:443QuickPulse https://rt.services.visualstudio.com:443
  • ApplicationIdProvider https://dc.services.visualstudio.com:443ApplicationIdProvider https://dc.services.visualstudio.com:443
  • TelemetryChannel https://dc.services.visualstudio.com:443TelemetryChannel https://dc.services.visualstudio.com:443

此处查看服务和 IP 地址的完整列表。Review our full list of services and IP addresses here.

防火墙例外Firewall exception

允许 Web 服务器将遥测发送到我们的终结点。Allow your web server to send telemetry to our endpoints.

网关重定向Gateway redirect

通过重写配置中的终结点,将流量从服务器路由到 Intranet 上的网关。Route traffic from your server to a gateway on your intranet by overwriting Endpoints in your configuration. 如果配置中不存在这些“终结点”属性,则这些类将使用下面示例 ApplicationInsights.config 中显示的默认值。If these "Endpoint" properties are not present in your config, these classes will use the default values shown below in the example ApplicationInsights.config.

你的网关应将流量路由到我们的终结点的基址。Your gateway should route traffic to our endpoint's base address. 在你的配置中,将默认值替换为 http://<your.gateway.address>/<relative path>In your configuration, replace the default values with http://<your.gateway.address>/<relative path>.

使用默认终结点的示例 ApplicationInsights.config:Example ApplicationInsights.config with default endpoints:
<ApplicationInsights>
  ...
  <TelemetryModules>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector">
      <QuickPulseServiceEndpoint>https://rt.services.visualstudio.com/QuickPulseService.svc</QuickPulseServiceEndpoint>
    </Add>
  </TelemetryModules>
    ...
  <TelemetryChannel>
     <EndpointAddress>https://dc.services.visualstudio.com/v2/track</EndpointAddress>
  </TelemetryChannel>
  ...
  <ApplicationIdProvider Type="Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights">
    <ProfileQueryEndpoint>https://dc.services.visualstudio.com/api/profiles/{0}/appId</ProfileQueryEndpoint>
  </ApplicationIdProvider>
  ...
</ApplicationInsights>

备注

自 v2.6.0 开始提供 ApplicationIdProvider 功能。ApplicationIdProvider is available starting in v2.6.0.

代理透传Proxy passthrough

可以通过配置计算机级代理或应用程序级代理来实现代理透传。Proxy passthrough can be achieved by configuring either a machine level or application level proxy. 有关详细信息,请参阅 dotnet 关于 DefaultProxy 的文章。For more information see dotnet's article on DefaultProxy.

示例 Web.config:Example Web.config:

<system.net>
   <defaultProxy>
     <proxy proxyaddress="http://xx.xx.xx.xx:yyyy" bypassonlocal="true"/>
   </defaultProxy>
</system.net>

是否可以在 Intranet 服务器上运行可用性 Web 测试?Can I run Availability web tests on an intranet server?

我们的 Web 测试可在遍布全球的各个接入点上运行。Our web tests run on points of presence that are distributed around the globe. 可运用以下两种解决方案:There are two solutions:

  • 防火墙门 - 允许从长且可更改的 Web 测试代理列表中请求自己的服务器。Firewall door - Allow requests to your server from the long and changeable list of web test agents.
  • 编写自己的代码,从 Intranet 内部向服务器发送定期请求。Write your own code to send periodic requests to your server from inside your intranet. 可以为此运行 Visual Studio Web 测试。You could run Visual Studio web tests for this purpose. 测试人员可以使用 TrackAvailability() API 将结果发送到 Application Insights。The tester could send the results to Application Insights using the TrackAvailability() API.

收集遥测数据需要多长时间?How long does it take for telemetry to be collected?

大多数 Application Insights 数据的延迟小于 5 分钟。Most Application Insights data has a latency of under 5 minutes. 有些数据可能需要更长的时间,通常是较大的日志文件。Some data can take longer; typically larger log files.

用于容器的 Azure MonitorAzure Monitor for containers

本 Microsoft 常见问题解答列出了用于容器的 Azure Monitor 的常见问题。This Microsoft FAQ is a list of commonly asked questions about Azure Monitor for containers. 如果对该解决方案还有其他任何问题,请访问 support-azure 并发布问题。If you have any additional questions about the solution, go to the support-azure and post your questions. 当某个问题经常被问到时,我们会将该问题添加到本文中,以便可以轻松快捷地找到该问题。When a question is frequently asked, we add it to this article so that it can be found quickly and easily.

其他进程 在节点视图下表示什么?What does Other Processes represent under the Node view?

“其他进程”旨在帮助你清楚了解节点上资源使用率较高的根本原因。Other processes is intended to help you clearly understand the root cause of the high resource usage on your node. 让你可以区分容器化进程与非容器化进程之间的使用情况。This enables you to distinguish usage between containerized processes vs non-containerized processes.

这些“其他进程”是什么?What are these Other Processes?

这些是运行在节点上的非容器化进程。These are non-containerized processes that run on your node.

如何对其进行计算?How do we calculate this?

其他进程 = CAdvisor 中的总用量 - 容器化进程的用量 Other Processes = Total usage from CAdvisor - Usage from containerized process

“其他进程”包括:The Other processes includes:

  • 自行托管的或托管 Kubernetes 非容器化进程Self-managed or managed Kubernetes non-containerized processes

  • 容器运行时进程Container Run-time processes

  • KubeletKubelet

  • 节点上运行的系统进程System processes running on your node

  • 其他在节点硬件或 VM 上运行的非 Kubernetes 工作负载Other non-Kubernetes workloads running on node hardware or VM

我看不到在查询 ContainerLog 表时填充的图像和名称属性值。I don't see Image and Name property values populated when I query the ContainerLog table.

对于代理版本 ciprod12042019 和更高版本,默认情况下,不会为每个日志行填充这两个属性,这样是为了最大程度地减少收集日志数据时产生的成本。For agent version ciprod12042019 and later, by default these two properties are not populated for every log line to minimize cost incurred on log data collected. 有两个可用于查询表的选项,其中包含这些属性及其值:There are two options to query the table that include these properties with their values:

选项 1Option 1

联接其他表以在结果中包含这些属性值。Join other tables to include these property values in the results.

通过在 ContainerID 属性上进行联接,将查询修改为包含 ContainerInventory 表中的 Image 和 ImageTag 属性。Modify your queries to include Image and ImageTag properties from the ContainerInventory table by joining on ContainerID property. 通过在 ContainerID 属性上进行联接,可以包含 KubepodInventory 表的 ContaineName 字段中的 Name 属性(与以前在 ContainerLog 表中显示的相同)。建议使用此选项。You can include the Name property (as it previously appeared in the ContainerLog table) from KubepodInventory table's ContaineName field by joining on the ContainerID property.This is the recommended option.

下面的示例是一个示例详细查询,说明如何使用联接获取这些字段值。The following example is a sample detailed query that explains how to get these field values with joins.

//lets say we are querying an hour worth of logs
let startTime = ago(1h);
let endTime = now();
//below gets the latest Image & ImageTag for every containerID, during the time window
let ContainerInv = ContainerInventory | where TimeGenerated >= startTime and TimeGenerated < endTime | summarize arg_max(TimeGenerated, *)  by ContainerID, Image, ImageTag | project-away TimeGenerated | project ContainerID1=ContainerID, Image1=Image ,ImageTag1=ImageTag;
//below gets the latest Name for every containerID, during the time window
let KubePodInv  = KubePodInventory | where ContainerID != "" | where TimeGenerated >= startTime | where TimeGenerated < endTime | summarize arg_max(TimeGenerated, *)  by ContainerID2 = ContainerID, Name1=ContainerName | project ContainerID2 , Name1;
//now join the above 2 to get a 'jointed table' that has name, image & imagetag. Outer left is safer in-case there are no kubepod records are if they are latent
let ContainerData = ContainerInv | join kind=leftouter (KubePodInv) on $left.ContainerID1 == $right.ContainerID2;
//now join ContainerLog table with the 'jointed table' above and project-away redundant fields/columns and rename columns that were re-written
//Outer left is safer so you dont lose logs even if we cannot find container metadata for loglines (due to latency, time skew between data types etc...)
ContainerLog
| where TimeGenerated >= startTime and TimeGenerated < endTime 
| join kind= leftouter (
   ContainerData
) on $left.ContainerID == $right.ContainerID2 | project-away ContainerID1, ContainerID2, Name, Image, ImageTag | project-rename Name = Name1, Image=Image1, ImageTag=ImageTag1 

方法 2Option 2

为每个容器日志行的这些属性重新启用收集。Re-enable collection for these properties for every container log line.

如果第一个选项因涉及到查询更改而不方便,则可通过在代理配置映射中启用设置 log_collection_settings.enrich_container_logs 来重新启用收集这些字段的功能,如数据收集配置设置中所述。If the first option is not convenient due to query changes involved, you can re-enable collecting these fields by enabling the setting log_collection_settings.enrich_container_logs in the agent config map as described in the data collection configuration settings.

备注

对于包含 50 个以上节点的大型群集,不建议使用第二个选项,因为它将从群集中的每个节点生成 API 服务器调用以执行此扩充。The second option is not recommended with large clusters that have more than 50 nodes because it generates API server calls from every node in the cluster to perform this enrichment. 此选项还会增加收集的每个日志行的数据大小。This option also increases data size for every log line collected.

能否查看在 Grafana 中收集的指标?Can I view metrics collected in Grafana?

用于容器的 Azure Monitor 支持在 Grafana 仪表板中查看 Log Analytics 工作区中存储的度量值。Azure Monitor for containers supports viewing metrics stored in your Log Analytics workspace in Grafana dashboards. 我们提供了一个模板。你可以从 Grafana 的仪表板存储库下载该模板来开始操作,并可通过该模板来了解如何从受监视的群集查询更多数据,以便在自定义 Grafana 仪表板中进行可视化。We have provided a template that you can download from Grafana's dashboard repository to get you started and reference to help you learn how to query additional data from your monitored clusters to visualize in custom Grafana dashboards.

是否可以使用用于容器的 Azure Monitor 监视 AKS-engine 群集?Can I monitor my AKS-engine cluster with Azure Monitor for containers?

用于容器的 Azure Monitor 支持监视部署到 Azure 上托管的 AKS-engine(以前称为 ACS-engine)群集的容器工作负荷。Azure Monitor for containers supports monitoring container workloads deployed to AKS-engine (formerly known as ACS-engine) cluster(s) hosted on Azure. 有关为此方案启用监视所需步骤的进一步详细信息和概述,请参阅将用于容器的 Azure Monitor 用于 AKS-engineFor further details and an overview of steps required to enable monitoring for this scenario, see Using Azure Monitor for containers for AKS-engine.

为何 Log Analytics 工作区中不显示数据?Why don't I see data in my Log Analytics workspace?

如果在每天的某个时间,在 Log Analytics 工作区中看不到任何数据,则可能已达到 500 MB 的默认限制或为了控制每天要收集的数据量而指定的每日上限。If you are unable to see any data in the Log Analytics workspace at a certain time everyday, you may have reached the default 500 MB limit or the daily cap specified to control the amount of data to collect daily. 如果当天的限制已达到,则数据收集将停止,并且仅在第二天恢复。When the limit is met for the day, data collection stops and resumes only on the next day. 若要查看数据使用情况,并根据预期的使用模式更新为不同的定价层,请参阅日志数据使用情况和成本To review your data usage and update to a different pricing tier based on your anticipated usage patterns, see Log data usage and cost.

ContainerInventory 表中指定的容器状态是什么?What are the container states specified in the ContainerInventory table?

ContainerInventory 表包含已停止和正在运行的容器的信息。The ContainerInventory table contains information about both stopped and running containers. 此表由代理中的一个工作流进行填充,该工作流查询 Docker 中的所有容器(正在运行的和已停止的),并将该数据转发到 Log Analytics 工作区。The table is populated by a workflow inside the agent that queries the docker for all the containers (running and stopped), and forwards that data the Log Analytics workspace.

如何解决“缺少订阅注册”错误?How do I resolve Missing Subscription registration error?

如果收到“缺少 Microsoft.OperationsManagement 的订阅注册”错误,则可以通过在定义了工作区的订阅中注册资源提供程序 Microsoft.OperationsManagement 来解决该错误。If you receive the error Missing Subscription registration for Microsoft.OperationsManagement, you can resolve it by registering the resource provider Microsoft.OperationsManagement in the subscription where the workspace is defined. 可以在此处找到介绍如何执行此操作的文档。The documentation for how to do this can be found here.

是否支持启用了 RBAC 的 AKS 群集?Is there support for RBAC enabled AKS clusters?

容器监视解决方案不支持 RBAC,但用于容器的 Azure Monitor 支持 RBAC。The Container Monitoring solution doesn't support RBAC, but it is supported with Azure Monitor for Containers. 在显示这些群集的数据的边栏选项卡上,解决方案详细信息页可能不会显示正确的信息。The solution details page may not show the right information in the blades that show data for these clusters.

如何通过 Helm 为 kube-system 命名空间中的容器启用日志收集?How do I enable log collection for containers in the kube-system namespace through Helm?

默认情况下,kube-system 命名空间中的容器的日志收集被禁用。The log collection from containers in the kube-system namespace is disabled by default. 可以通过在 omsagent 上设置一个环境变量来启用日志收集。Log collection can be enabled by setting an environment variable on the omsagent. 有关详细信息,请参阅用于容器的 Azure Monitor GitHub 页。For more information, see the Azure Monitor for containers GitHub page.

如何将 omsagent 更新为最新发布的版本?How do I update the omsagent to the latest released version?

若要了解如何升级代理,请参阅代理管理To learn how to upgrade the agent, see Agent management.

如何启用多行日志记录?How do I enable multi-line logging?

当前,用于容器的 Azure Monitor 不支持多行日志记录,但有可用的变通方法。Currently Azure Monitor for containers doesn't support multi-line logging, but there are workarounds available. 你可以将所有服务配置为以 JSON 格式进行写入,然后 Docker/Moby 会在单个行上写入它们。You can configure all the services to write in JSON format and then Docker/Moby will write them as a single line.

例如,可以将你的日志包装为一个 JSON 对象,如示例 node.js 应用程序的以下示例中所示:For example, you can wrap your log as a JSON object as shown in the example below for a sample node.js application:

console.log(json.stringify({ 
      "Hello": "This example has multiple lines:",
      "Docker/Moby": "will not break this into multiple lines",
      "and you will receive":"all of them in log analytics",
      "as one": "log entry"
      }));

在你查询时,此数据将类似于用于日志的 Azure Monitor 中的以下示例:This data will look like the following example in Azure Monitor for logs when you query for it:

LogEntry : ({"Hello": "This example has multiple lines:","Docker/Moby": "will not break this into multiple lines", "and you will receive":"all of them in log analytics", "as one": "log entry"}

有关此问题的详细信息,请查看以下 GitHub 链接For a detailed look at the issue, review the following GitHub link.

如何解决启用实时日志时遇到的 Azure AD 错误?How do I resolve Azure AD errors when I enable live logs?

你可能会看到以下错误:在请求中指定的回复 URL 与为应用程序“<应用程序 ID>”配置的回复 URL 不匹配You may see the following error: The reply url specified in the request does not match the reply urls configured for the application: '<application ID>'.

为何在载入后不能升级群集?Why can't I upgrade cluster after onboarding?

如果为 AKS 群集启用用于容器的 Azure Monitor 后,删除了该群集将其数据发送到的 Log Analytics 工作区,则尝试升级该群集时,该操作将会失败。If after you enable Azure Monitor for containers for an AKS cluster, you delete the Log Analytics workspace the cluster was sending its data to, when attempting to upgrade the cluster it will fail. 若要解决这一问题,必须禁用监视,然后重新启用该监视,同时引用订阅中的另一个有效工作区。To work around this, you will have to disable monitoring and then re-enable it referencing a different valid workspace in your subscription. 当你尝试再次升级群集时,该升级操作应进行处理并成功完成。When you try to perform the cluster upgrade again, it should process and complete successfully.

需要为代理打开哪些端口和域,或将哪些端口和域加入允许列表?Which ports and domains do I need to open/whitelist for the agent?

有关 Azure 云、Azure 美国政府云和 Azure 中国世纪互联云的容器化代理所需的代理和防火墙配置信息,请参阅网络防火墙要求See the Network firewall requirements for the proxy and firewall configuration information required for the containerized agent with Azure, Azure US Government, and Azure China 21Vianet clouds.

用于 VM 的 Azure MonitorAzure Monitor for VMs

本 Microsoft 常见问题解答列出了用于 VM 的 Azure Monitor 的常见问题。This Microsoft FAQ is a list of commonly asked questions about Azure Monitor for VMs. 如果对该解决方案还有其他任何问题,请访问论坛并发布问题。If you have any additional questions about the solution, go to the discussion forum and post your questions. 当某个问题经常被问到时,我们会将该问题添加到本文中,以便可以轻松快捷地找到该问题。When a question is frequently asked, we add it to this article so that it can be found quickly and easily.

是否可以载入到现有工作区?Can I onboard to an existing workspace?

如果虚拟机已连接到 Log Analytics 工作区,则在载入到用于 VM 的 Azure Monitor 时,可以继续使用该工作区,前提是该工作区位于某个受支持区域中。If your virtual machines are already connected to a Log Analytics workspace, you may continue to use that workspace when onboarding to Azure Monitor for VMs, provided it is in one of the supported regions.

是否可以载入到新工作区?Can I onboard to a new workspace?

如果 VM 当前未连接到现有的 Log Analytics 工作区,则你需要创建一个新工作区来存储数据。If your VMs are not currently connected to an existing Log Analytics workspace, you need to create a new workspace to store your data. 如果通过 Azure 门户为用于 VM 的 Azure Monitor 配置了单个 Azure VM,则系统会自动创建新的默认工作区。Creating a new default workspace is done automatically if you configure a single Azure VM for Azure Monitor for VMs through the Azure portal.

如果 VM 已开始向现有工作区报告,我该怎么做?What do I do if my VM is already reporting to an existing workspace?

如果你已开始从虚拟机收集数据,则可能已将虚拟机配置为向现有的 Log Analytics 工作区报告数据。If you are already collecting data from your virtual machines, you may have already configured it to report data to an existing Log Analytics workspace. 只要该工作区在某个受支持区域中,就可以在该现有工作区中启用用于 VM 的 Azure Monitor。As long as that workspace is in one of our supported regions, you can enable Azure Monitor for VMs to that pre-existing workspace. 如果使用的工作区不在受支持的区域中,则目前无法载入到用于 VM 的 Azure Monitor。If the workspace you are already using is not in one of our supported regions, you won't be able to onboard to Azure Monitor for VMs at this time. 我们将力求支持更多的区域。We are actively working to support additional regions.

为何我的 VM 无法载入?Why did my VM fail to onboard?

从 Azure 门户载入 Azure VM 时,将执行以下步骤:When onboarding an Azure VM from the Azure portal, the following steps occur:

  • 创建默认的 Log Analytics 工作区(如果已选择该选项)。A default Log Analytics workspace is created, if that option was selected.
  • 使用 VM 扩展在 Azure VM 上安装 Log Analytics 代理(如果确定有必要)。The Log Analytics agent is installed on Azure VMs using a VM extension, if determined it is required.
  • 使用某个扩展在 Azure VM 上安装用于 VM 的 Azure Monitor 映射依赖项代理(如果确定有必要)。The Azure Monitor for VMs Map Dependency agent is installed on Azure VMs using an extension, if determined it is required.

在载入过程中,我们会检查上述每个步骤的状态,并在门户中返回通知状态。During the onboard process, we check for status on each of the above to return a notification status to you in the portal. 配置工作区和安装代理通常需要 5 到 10 分钟。Configuration of the workspace and the agent installation typically takes 5 to 10 minutes. 在门户中查看监视数据需要额外 5 到 10 分钟的时间。Viewing monitoring data in the portal take an additional 5 to 10 minutes.

如果在启动载入后有消息指出 VM 需要载入,则 VM 最长需要花费 30 分钟来完成该过程。If you have initiated onboarding and see messages indicating the VM needs to be onboarded, allow for up to 30 minutes for the VM to complete the process.

我的 VM 性能图表中未显示某些或任何数据I don't see some or any data in the performance charts for my VM

已对性能图表进行更新以使用存储在 InsightsMetrics 表中的数据。Our performance charts have been updated to use data stored in the InsightsMetrics table. 若要查看这些图表中的数据,需要升级才能使用新的 VM Insights 解决方案。To see data in these charts you will need to upgrade to use the new VM Insights solution.

用于 VM 的 Azure Monitor 映射功能与服务映射有何不同?How is Azure Monitor for VMs Map feature different from Service Map?

用于 VM 的 Azure Monitor 映射功能基于服务映射,但存在以下差异:The Azure Monitor for VMs Map feature is based on Service Map, but has the following differences:

  • 可以从“VM”边栏选项卡,或者 Azure Monitor 中的“用于 VM 的 Azure Monitor”访问“映射”视图。The Map view can be accessed from the VM blade and from Azure Monitor for VMs under Azure Monitor.
  • “映射”中的连接现在可单击,所选连接的边侧面板中会显示连接指标数据的视图。The connections in the Map are now clickable and display a view of the connection metric data in the side panel for the selected connection.
  • 可以使用一个新 API 创建映射,以便更好地支持更复杂的映射。There is a new API that is used to create the maps to better support more complex maps.
  • 受监视 VM 现在包含在客户端组节点中,圆环图显示该组中受监视与不受监视虚拟机的比例。Monitored VMs are now included in the client group node, and the donut chart shows the proportion of monitored vs unmonitored virtual machines in the group. 展开该组后,还可以在该图表中筛选计算机列表。It can also be used to filter the list of machines when the group is expanded.
  • 受监视虚拟机现在包含在服务器端口组节点中,圆环图显示该组中受监视与不受监视虚拟机的比例。Monitored virtual machines are now included in the server port group nodes, and the donut chart shows the proportion of monitored vs unmonitored machines in the group. 展开该组后,还可以在该图表中筛选计算机列表。It can also be used to filter the list of machines when the group is expanded.
  • 映射样式已更新,与 Application Insights 中的应用映射更一致。The map style has been updated to be more consistent with App Map from Application insights.
  • 侧面板已更新,但并未包含服务映射中支持的整套集成功能 -“更新管理”、“更改跟踪”、“安全性”和“服务台”。The side panels have been updated, and do not have the full set of integration's that were supported in Service Map - Update Management, Change Tracking, Security, and Service Desk.
  • 用于选择要映射的组和计算机的选项已更新,现在支持订阅、资源组、Azure 虚拟机规模集和云服务。The option for choosing groups and machines to map has been updated and now supports Subscriptions, Resource Groups, Azure virtual machine scale sets, and Cloud services.
  • 无法在用于 VM 的 Azure Monitor 映射功能中创建新的服务映射计算机组。You cannot create new Service Map machine groups in the Azure Monitor for VMs Map feature.

为何我的性能图表显示虚线?Why do my performance charts show dotted lines?

这有几个原因。This can occur for a few reasons. 如果数据集合中存在间隙,则我们会绘制虚线。In cases where there is a gap in data collection we depict the lines as dotted. 如果为启用的性能计数器修改了数据采样频率(默认设置为每隔 60 秒收集数据),并且为图表选择较窄的时间范围,而采样频率小于图表中使用的桶大小(例如,采样频率为每隔 10 分钟,图表上的每个桶为 5 分钟),则可能会在图表中看到虚线。If you have modified the data sampling frequency for the performance counters enabled (the default setting is to collect data every 60 seconds), you can see dotted lines in the chart if you choose a narrow time range for the chart and your sampling frequency is less than the bucket size used in the chart (for example, the sampling frequency is every 10 minutes and each bucket on the chart is 5 minutes). 在这种情况下,选择查看更宽的时间范围应该可使图表线条显示为实线而不是虚线。Choosing a wider time range to view should cause the chart lines to appear as solid lines rather than dots in this case.

用于 VM 的 Azure Monitor 是否支持组?Are groups supported with Azure Monitor for VMs?

是,一旦安装依赖项代理,我们就会从 VM 中收集信息,以根据订阅、资源组、虚拟机规模集和云服务显示组。Yes, once you install the Dependency agent we collect information from the VMs to display groups based upon subscription, resource group, virtual machine scale sets, and cloud services. 如果你一直在使用服务映射并创建了计算机组,则也会显示这些组。If you have been using Service Map and have created machine groups, these are displayed as well. 如果你为正在查看的工作区创建了计算机组,那么这些组也会显示在组筛选器中。Computer groups will also appear in the groups filter if you have created them for the workspace you are viewing.

如何查看聚合性能图表中驱动第 95 百分位线条的详细信息?How do I see the details for what is driving the 95th percentile line in the aggregate performance charts?

默认情况下,列表已经过排序,会显示所选指标的第 95 百分位值最大的 VM,但“可用内存”图表除外,其中显示第 5 百分位值最小的计算机。By default, the list is sorted to show you the VMs that have the highest value for the 95th percentile for the selected metric, except for the Available memory chart, which shows the machines with the lowest value of the 5th percentile. 单击图表会打开“前 N 项列表”视图,其中已选择相应的指标。Clicking on the chart will open the Top N List view with the appropriate metric selected.

“映射”功能如何处理不同 VNet 和子网中的重复 IP?How does the Map feature handle duplicate IPs across different vnets and subnets?

如果跨子网和 VNet 复制 VM 或 Azure 虚拟机规模集的 IP 范围,可能导致用于 VM 的 Azure Monitor 映射显示错误的信息。If you are duplicating IP ranges either with VMs or Azure virtual machine scale sets across subnets and vnets, it can cause Azure Monitor for VMs Map to display incorrect information. 这是一个已知问题,我们正在研究可改进此体验的选项。This is a known issue and we are investigating options to improve this experience.

“映射”功能是否支持 IPv6?Does Map feature support IPv6?

“映射”功能目前仅支持 IPv4,我们正在研究 IPv6 的支持。Map feature currently only supports IPv4 and we are investigating support for IPv6. 我们还支持 IPv6 隧道内部的 IPv4。We also support IPv4 that is tunneled inside IPv6.

加载资源组或其他大型组的映射时,难以查看映射When I load a map for a Resource Group or other large group the map is difficult to view

尽管我们已对“映射”做出改进,使其能够处理大型和复杂的配置,但我们认识到,映射中可能包含大量以群集方式工作的节点和连接。While we have made improvements to Map to handle large and complex configurations, we realize a map can have a lot of nodes, connections, and node working as a cluster. 我们将持续致力增强支持以提高可伸缩性。We are committed to continuing to enhance support to increase scalability.

为何“性能”选项卡上的网络图表不同于 Azure VM“概述”页上的网络图表?Why does the network chart on the Performance tab look different than the network chart on the Azure VM Overview page?

Azure VM 的概述页基于来宾 VM 中的活动的主机度量值显示图表。The overview page for an Azure VM displays charts based on the host's measurement of activity in the guest VM. Azure VM“概述”中的网络图表仅显示计费的网络流量。For the network chart on the Azure VM Overview, it only displays network traffic that will be billed. 这不包括虚拟网络之间的流量。This does not include inter-virtual network traffic. 针对用于 VM 的 Azure Monitor 显示的数据和图表基于来宾 VM 中的数据,网络图表显示入站和出站到该 VM 的所有 TCP/IP 流量,包括虚拟网络间的流量。The data and charts shown for Azure Monitor for VMs is based on data from the guest VM and the network chart displays all TCP/IP traffic that is inbound and outbound to that VM, including inter-virtual network.

如何测量存储在 VMConnection 中并显示在连接面板和工作簿中的数据的响应时间?How is response time measured for data stored in VMConnection and displayed in the connection panel and workbooks?

响应时间是近似值。Response time is an approximation. 由于我们没有检测应用程序的代码,因此我们并不真正知道请求何时开始以及响应何时到达。Since we do not instrument the code of the application, we do not really know when a request begins and when the response arrives. 但是,我们观察到通过连接发送数据,然后通过该连接返回数据。Instead we observe data being sent on a connection and then data coming back on that connection. 我们的代理跟踪这些发送和接收操作并尝试对它们进行配对:一个发送序列后跟一个接收序列将解释为一个请求/响应对。Our agent keeps track of these sends and receives and attempts to pair them: a sequence of sends, followed by a sequence of receives is interpreted as a request/response pair. 这些操作之间的时间间隔就是响应时间。The timing between these operations is the response time. 它将包括网络延迟和服务器处理时间。It will include the network latency and the server processing time.

这种近似适用于基于请求/响应的协议:单个请求在连接上发出,并且单个响应到达。This approximation works well for protocols that are request/response based: a single request goes out on the connection, and a single response arrives. 这是 HTTP(S) 的情况(没有流水线操作),但对于其他协议不太适合。This is the case for HTTP(S) (without pipelining), but not satisfied for other protocols.

如果我使用的是 Log Analytics 免费定价计划,它们有何限制?Are their limitations if I am on the Log Analytics Free pricing plan?

如果已经为 Azure Monitor 配置了使用免费定价层的 Log Analytics 工作区,则用于 VM 的 Azure Monitor 的映射功能将仅支持已连接到工作区的五台计算机。If you have configured Azure Monitor with a Log Analytics workspace using the Free pricing tier, Azure Monitor for VMs Map feature will only support five connected machines connected to the workspace. 如果已有五台 VM 连接到免费工作区,你断开了其中一台 VM 的连接,然后连接到一台新的 VM,则新的 VM 将不受监视并且不会反映在“映射”页上。If you have five VMs connected to a free workspace, you disconnect one of the VMs and then later connect a new VM, the new VM is not monitored and reflected on the Map page.

在这种情况下,当打开 VM 并从左侧窗格中选择“见解”时(甚至已在 VM 上安装后),系统都会通过“立即尝试”选项进行提示。 Under this condition, you will be prompted with the Try Now option when you open the VM and select Insights from the left-hand pane, even after it has been installed already on the VM. 但是,如果此 VM 未加入到用于 VM 的 Azure Monitor,则不会像通常情况下那样通过选项向你发出提示。However, you are not prompted with options as would normally occur if this VM were not onboarded to Azure Monitor for VMs.

后续步骤Next steps

如果本文未解答你遇到的问题,可在以下论坛中查看更多问题和解答。If your question isn't answered here, you can refer to the following forums to additional questions and answers.

有关 Azure Monitor 的一般反馈,请访问反馈论坛For general feedback on Azure Monitor please visit the feedback forum.