你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

定义 Azure Monitor 代理网络设置

Azure Monitor 代理支持使用直接代理、Log Analytics 网关和专用链接进行连接。 本文介绍如何为 Azure Monitor 代理定义网络设置并启用网络隔离。

虚拟网络服务标记

Azure Monitor 代理支持 Azure 虚拟网络服务标记。 AzureMonitor 和 AzureResourceManager 标记都是必需的。

Azure 虚拟网络服务标记可用于定义对网络安全组Azure 防火墙和用户定义的路由的网络访问控制。 创建安全规则和路由时,请使用服务标记代替特定 IP 地址。 对于无法使用 Azure 虚拟网络服务标记的场景,防火墙要求如下。

防火墙要求

端点 目的 端口 方向 绕过 HTTPS 检查 示例
Azure 商业版 global.handler.control.monitor.azure.com 访问控制服务 端口 443 出站 -
Azure 商业版 <virtual-machine-region-name>.handler.control.monitor.azure.com 提取特定计算机的数据收集规则 端口 443 出站 westus2.handler.control.monitor.azure.com
Azure 商业版 <log-analytics-workspace-id>.ods.opinsights.azure.com 引入日志数据 端口 443 出站 1234a123-aa1a-123a-aaa1-a1a345aa6789.ods.opinsights.azure.com
Azure 商业版 management.azure.com 仅当将时序数据(指标)发送到 Azure Monitor 自定义指标数据库时才需要 端口 443 出站 -
Azure 商业版 <virtual-machine-region-name>.monitoring.azure.com 仅当将时序数据(指标)发送到 Azure Monitor 自定义指标数据库时才需要 端口 443 出站 westus2.monitoring.azure.com
Azure 商业版 <data-collection-endpoint>.<virtual-machine-region-name>.ingest.monitor.azure.com 仅当将数据发送到 Log Analytics 自定义日志表时才需要 端口 443 出站 275test-01li.eastus2euap-1.canary.ingest.monitor.azure.com
Azure Government 将上面的“.com”替换为“.us” 同上 同上 同上 同上
由世纪互联运营的 Microsoft Azure 将上面的“.com”替换为“.cn” 同上 同上 同上 同上

注意

如果在代理上使用专用链接,必须添加专用数据收集终结点 (DCE)。 使用专用链接/数据收集终结点时,代理不使用上面列出的非专用终结点。 Azure Monitor 指标(自定义指标)预览版在 Azure 政府和由世纪互联运营的 Azure中不可用。

代理配置

如果计算机通过代理服务器建立连接,以便通过 Internet 进行通信,请查看以下要求来了解所需的网络配置。

适用于 Windows 和 Linux 的 Azure Monitor 代理扩展可以使用 HTTPS 协议通过代理服务器或 Log Analytics 网关与 Azure Monitor 进行通信。 请将其用于 Azure 虚拟机、Azure 虚拟机规模集和 Azure Arc for servers。 将扩展设置用于配置,如以下步骤所述。 匿名身份验证和基本身份验证(使用用户名/密码)都受支持。

重要

Azure Monitor 指标(公共预览版)不支持将代理配置作为目标。 如果将指标发送到此目标,则将使用没有任何代理的公共 Internet。

  1. 首先请使用此流程图来确定 SettingsProtectedSettings 参数的值。

    Diagram that shows a flowchart to determine the values of settings and protectedSettings parameters when you enable the extension.

    注意

    仅支持使用适用于 Linux 的 Azure Monitor 代理 1.24.2 及更高版本通过环境变量(如 http_proxyhttps_proxy)设置 Linux 系统代理。 对于 ARM 模板,如果有代理配置,请按照下面的 ARM 模板示例在 ARM 模板中声明代理设置。 此外,用户还可以通过 /etc/systemd/system.conf 中的 DefaultEnvironment 变量设置所有系统服务选取的“全局”环境变量。

  2. 确定 SettingsProtectedSettings 参数值后,请在部署 Azure Monitor 代理时提供这些其他参数。 使用 PowerShell 命令,如以下示例所示:

$settingsString = '{"proxy":{"mode":"application","address":"http://[address]:[port]","auth": "true"}}';
$protectedSettingsString = '{"proxy":{"username":"[username]","password": "[password]"}}';
Set-AzVMExtension -ExtensionName AzureMonitorWindowsAgent -ExtensionType AzureMonitorWindowsAgent -Publisher Microsoft.Azure.Monitor -ResourceGroupName <resource-group-name> -VMName <virtual-machine-name> -Location <location> -TypeHandlerVersion <type-handler-version> -SettingString $settingsString -ProtectedSettingString $protectedSettingsString

Log Analytics 网关配置

  1. 按照上述说明在代理上配置代理设置,并提供与网关服务器对应的 IP 地址和端口号。 如果已经在负载均衡器后面部署了多个网关服务器,代理配置会改为该负载均衡器的虚拟 IP 地址。
  2. 将“配置终结点 URL”添加到网关 Add-OMSGatewayAllowedHost -Host global.handler.control.monitor.azure.comAdd-OMSGatewayAllowedHost -Host <gateway-server-region-name>.handler.control.monitor.azure.com 的允许列表中,以提取数据收集规则。 (如果在代理上使用专用链接,还必须添加数据收集终结点。)
  3. 将数据引入终结点 URL 添加到网关 Add-OMSGatewayAllowedHost -Host <log-analytics-workspace-id>.ods.opinsights.azure.com 的允许列表中。
  4. 重启“OMS 网关”服务以应用更改 Stop-Service -Name <gateway-name>Start-Service -Name <gateway-name>

后续步骤