你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
本文介绍如何使用以下 Azure Monitor 功能启用 Kubernetes 群集的完整监视:
- 用于指标收集的托管 Prometheus
- 用于日志收集的容器见解
- 用于可视化的托管 Grafana。
使用 Azure 门户,可以同时启用所有这些功能。 还可以使用 Azure CLI、Azure 资源管理器模板、Terraform 或 Azure Policy 单独启用它们。 本文介绍了上述每种方法。
重要
Kubernetes 群集会生成大量日志数据,如果你对收集的日志没有选择性,可能会导致高昂的成本。 在启用群集监视之前,请参阅以下文章,以确保环境针对成本进行了优化,并将日志收集限制为仅收集所需的数据:
- 使用数据收集规则在容器见解中配置数据收集和成本优化
有关启用监视后自定义日志收集的详细信息,包括使用预设的成本优化配置。 - 使用 Azure Monitor 监视 Kubernetes 的最佳做法
根据 Azure 架构良好的框架的五大支柱(包括成本优化)整理的 Kubernetes 群集监视最佳实践。 - Azure Monitor 中的成本优化
有关配置 Azure Monitor 所有功能以优化成本并限制收集的数据量的最佳做法。
支持的群集
本文就以下类型的群集提供加入指南。 相关部分中介绍了每种类型过程中的任何差异。
先决条件
权限
托管 Prometheus 的先决条件
- 群集必须使用托管标识身份验证。
- 必须在群集和 Azure Monitor 工作区的订阅中注册以下资源提供程序:
- Microsoft.ContainerService (微软容器服务)
- Microsoft.Insights
- Microsoft.AlertsManagement
- Microsoft.Monitor
- 以下资源提供程序必须在 Grafana 工作区订阅中注册:
- Microsoft.Dashboard
已启用 Arc 的 Kubernetes 群集先决条件
- 请验证防火墙要求以及已启用 Azure Arc 的 Kubernetes 网络要求。
- 如果以前为 AKS 安装了监视,请务必禁用监视后再继续,以免在扩展安装过程中出现问题。
- 如果以前在没有群集扩展的情况下使用脚本在群集上安装监视,请按照禁用 Kubernetes 群集监视的说明来删除此 Helm 图表。
注意
托管 Prometheus 已启用 Arc 的 Kubernetes 扩展不支持以下配置:
- Red Hat Openshift 分发版,包括 Azure Red Hat OpenShift (ARO)
- Windows 节点*
*对于包含 Windows 节点的已启用 ARC 的群集,可以在群集中的 Linux 节点上设置 Azure 托管 Prometheus,并配置为从 Windows 节点上运行的指标终结点抓取指标。
工作区
下表描述了支持 Managed Prometheus 和容器洞察所需的工作区。 可在加入过程中创建每个工作区,或者使用现有工作区。 请参阅设计 Log Analytics 工作区体系结构,获取有关要创建多少个工作区以及应在何处放置工作区的指导。
功能 / 特点 | 工作区 | 说明 |
---|---|---|
托管 Prometheus | Azure Monitor 工作区 | Contributor 权限足以允许加载项将数据发送到 Azure Monitor 工作区。 若要链接 Azure Monitor 工作区以查看 Azure 托管 Grafana 中的指标,则需要 Owner 级别权限。 这是必需项,因为执行入门步骤的用户需要能够在 Azure Monitor 工作区上为 Azure 托管 Grafana 系统标识授予 Monitoring Reader 角色,以便查询指标。 |
容器见解 | Log Analytics 工作区 | 可以将群集附加到同一Microsoft Entra 租户中不同 Azure 订阅中的 Log Analytics 工作区,但必须使用 Azure CLI 或 Azure 资源管理器模板。 目前不能使用 Azure 门户执行此配置。 如果要将现有群集连接到另一订阅中的 Log Analytics 工作区,则必须在订阅中向 Log Analytics 工作区注册 Microsoft.ContainerService 资源提供程序。 有关详细信息,请参阅注册资源提供程序。 有关用于默认工作区的受支持映射对的列表,请参阅容器见解支持的区域映射。 关于如何将网络安全外围应用于工作区的配置指南,请参阅 配置 Azure Monitor 的网络安全外围。 |
托管 Grafana | Azure 托管 Grafana 工作区 | 将 Grafana 工作区链接到 Azure Monitor 工作区,以使从群集收集的 Prometheus 指标可供 Grafana 仪表板使用。 |
启用 Prometheus 和 Grafana
使用以下方法之一可以从群集中抓取 Prometheus 指标,并启用 Managed Grafana 来可视化指标。 有关连接 Azure Monitor 工作区和 Azure 托管 Grafana 工作区的选项,请参阅链接 Grafana 工作区。
重要
如果使用模板或 Azure Policy 进行部署,请确保命名了数据收集终结点、数据收集规则和数据收集规则关联
MSProm-<Location of Azure Monitor Workspace>-<Name of cluster resource>
,或者载入过程不会成功完成。如果您有一个私有链接的 Azure Monitor 资源,那么如果 AKS 群集和 Azure Monitor 工作区位于不同区域,Prometheus 启用将无法正常工作。 在同一群集区域中创建新的 DCE 和 DCRA。 将新的 DCE 与群集相关联,并将新的 DCRA 命名为
configurationAccessEndpoint
。 请参阅在 Azure Monitor 中为 Kubernetes 监视启用专用链接。
使用 CLI 启用
如果未在以下命令中指定现有的 Azure Monitor 工作区,则将使用资源组的默认工作区。 如果群集所在区域尚不存在默认工作区,则将在一个名为 DefaultAzureMonitorWorkspace-<mapped_region>
的资源组中创建一个名称格式为 DefaultRG-<cluster_region>
的工作区。
先决条件
- 需要 Az CLI 2.49.0 或更高版本。
- 必须使用命令中卸载 aks-preview 扩展。
- 必须使用
az extension add --name k8s-extension
命令安装 k8s-extension 扩展。 - 需要 k8s-extension 版本 1.4.1 或更高版本。
可选参数
AKS 和 Arc-Enabled Kubernetes 的每个命令都允许以下可选参数。 每个参数名称不同,但它们的使用是相同的。
参数 | 名称和说明 |
---|---|
批注键 | AKS:--ksm-metric-annotations-allow-list Arc: --AzureMonitorMetrics.KubeStateMetrics.MetricAnnotationsAllowList 在资源的 kube_resource_annotations 指标中使用的 Kubernetes 注释键的逗号分隔列表。 例如,kube_pod_annotations 是 pod 资源的注释指标。 默认情况下,此指标仅包含名称和命名空间标签。 若要包含更多注释,请提供资源名称(复数形式)和要允许使用的 Kubernetes 注释键的列表。 可为每个资源提供一个 * 以允许任何注释,但这会严重影响性能。 例如 pods=[kubernetes.io/team,...],namespaces=[kubernetes.io/team],... 。 |
标签键 | AKS:--ksm-metric-labels-allow-list Arc: --AzureMonitorMetrics.KubeStateMetrics.MetricLabelsAllowlist 资源的 kube_resource_labels 指标中使用的更多 Kubernetes 标签键的逗号分隔列表。 例如,kube_pod_labels 是 Pod 资源的标签指标。 默认情况下,此指标仅包含名称和命名空间标签。 若要包含更多标签,请提供一个复数形式的资源名称列表以及想要允许这些资源使用的 Kubernetes 标签键。可为每个资源提供一个 * 以允许任何标签,但这会严重影响性能。 例如 pods=[app],namespaces=[k8s-label-1,k8s-label-n,...],... 。 |
记录规则 | AKS:--enable-windows-recording-rules 允许启用 Windows 仪表板正常运行所需的记录规则组。 |
AKS 群集
使用 -enable-azure-monitor-metrics
选项 az aks create
或 az aks update
(具体取决于是要创建新群集还是要更新现有群集)来安装用于擦除 Prometheus 指标的指标加载项。
### Use default Azure Monitor workspace
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group>
### Use existing Azure Monitor workspace
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group> --azure-monitor-workspace-resource-id <workspace-name-resource-id>
### Use an existing Azure Monitor workspace and link with an existing Grafana workspace
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group> --azure-monitor-workspace-resource-id <azure-monitor-workspace-name-resource-id> --grafana-resource-id <grafana-workspace-name-resource-id>
### Use optional parameters
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group> --ksm-metric-labels-allow-list "namespaces=[k8s-label-1,k8s-label-n]" --ksm-metric-annotations-allow-list "pods=[k8s-annotation-1,k8s-annotation-n]"
已启用 Arc 的群集
### Use default Azure Monitor workspace
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics
## Use existing Azure Monitor workspace
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id=<workspace-name-resource-id>
### Use an existing Azure Monitor workspace and link with an existing Grafana workspace
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id=<workspace-name-resource-id> grafana-resource-id=<grafana-workspace-name-resource-id>
### Use optional parameters
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id=<workspace-name-resource-id> grafana-resource-id=<grafana-workspace-name-resource-id> AzureMonitorMetrics.KubeStateMetrics.MetricAnnotationsAllowList="pods=[k8s-annotation-1,k8s-annotation-n]" AzureMonitorMetrics.KubeStateMetrics.MetricLabelsAllowlist "namespaces=[k8s-label-1,k8s-label-n]"
以下附加可选参数可用于已启用 Azure Arc 的群集:
参数 | 说明 | 违约 | 上游 Arc 群集设置 |
---|---|---|---|
ClusterDistribution |
群集的分布。 | Azure.Cluster.Distribution |
是的 |
CloudEnvironment |
群集的云环境。 | Azure.Cluster.Cloud |
是的 |
MountCATrustAnchorsDirectory |
是否装载 CA 信任定位点目录。 | true |
不 |
MountUbuntuCACertDirectory |
是否装载 Ubuntu CA 证书目录。 | 除非 true 发行版,否则 aks_edge 。 |
不 |
启用容器见解
按照下述方法之一在群集中启用容器见解。 完成此操作后,请参阅配置容器见解的代理数据收集来自定义配置,确保收集的数据量不超过所需的量。
重要
如果你拥有一个具有专用链接的 Azure Monitor 资源,则无法通过 Azure 门户启用容器见解。 请参阅 在 Azure Monitor 中为 Kubernetes 监控启用专用链接。
要启用使用网络安全边界的容器见解,请参阅使用网络安全边界配置 Azure Monitor 来配置 Log Analytics 工作区。
使用下述命令之一来启用对 AKS 和已启用 Arc 的群集的监视。 如果未指定现有的 Log Analytics 工作区,将使用资源组的默认工作区。 如果群集区域中尚不存在默认工作区,会使用 DefaultWorkspace-<GUID>-<Region>
格式的名称创建一个工作区。
先决条件
- Azure CLI 版本 2.43.0 或更高版本
- 托管标识身份验证是 CLI 版本 2.49.0 或更高版本中的默认设置。
- Azure k8s-extension 版本 1.3.7 或更高
- 托管身份认证是 k8s-extension 版本 1.43.0 或更高版本中的默认机制。
- 使用 ARO (Azure Red Hat Openshift) 或 Windows 节点且已启用 Arc 的 Kubernetes 群集不支持托管标识身份验证。 使用旧式身份验证。
- 对于 CLI 2.54.0 或更高版本,会使用 ConfigMap 将日志记录架构将配置为 ContainerLogV2。
注意
可以使用群集的数据收集规则 (DCR) 或 ConfigMap 为群集启用 ContainerLogV2 架构。 如果同时启用这两个设置,ConfigMap 优先级更高。 仅当 DCR 和 ConfigMap 都明确设置为关闭时,Stdout 和 stderr 日志才会引入到 ContainerLog 表。
AKS 群集
### Use default Log Analytics workspace
az aks enable-addons --addon monitoring --name <cluster-name> --resource-group <cluster-resource-group-name>
### Use existing Log Analytics workspace
az aks enable-addons --addon monitoring --name <cluster-name> --resource-group <cluster-resource-group-name> --workspace-resource-id <workspace-resource-id>
### Use legacy authentication
az aks enable-addons --addon monitoring --name <cluster-name> --resource-group <cluster-resource-group-name> --workspace-resource-id <workspace-resource-id> --enable-msi-auth-for-monitoring false
示例
az aks enable-addons --addon monitoring --name "my-cluster" --resource-group "my-resource-group" --workspace-resource-id "/subscriptions/my-subscription/resourceGroups/my-resource-group/providers/Microsoft.OperationalInsights/workspaces/my-workspace"
已启用 Arc 的群集
### Use default Log Analytics workspace
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers
### Use existing Log Analytics workspace
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings logAnalyticsWorkspaceResourceID=<workspace-resource-id>
### Use managed identity authentication (default as k8s-extension version 1.43.0)
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings amalogs.useAADAuth=true
### Use advanced configuration settings
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings amalogs.resources.daemonset.limits.cpu=150m amalogs.resources.daemonset.limits.memory=600Mi amalogs.resources.deployment.limits.cpu=1 amalogs.resources.deployment.limits.memory=750Mi
### With custom mount path for container stdout & stderr logs
### Custom mount path not required for Azure Stack Edge version > 2318. Custom mount path must be /home/data/docker for Azure Stack Edge cluster with version <= 2318
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings amalogs.logsettings.custommountpath=<customMountPath>
请参阅 Helm 图表的资源请求和限制部分,了解可用的配置设置。
示例
az k8s-extension create --name azuremonitor-containers --cluster-name "my-cluster" --resource-group "my-resource-group" --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings logAnalyticsWorkspaceResourceID="/subscriptions/my-subscription/resourceGroups/my-resource-group/providers/Microsoft.OperationalInsights/workspaces/my-workspace"
具有正向代理的已启用 Arc 的群集
如果群集配置了正向代理,则代理设置会自动应用于扩展。 对于使用 AMPLS + 代理的群集,应忽略代理配置。 使用配置设置 amalogs.ignoreExtensionProxySettings=true
载入扩展。
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings amalogs.ignoreExtensionProxySettings=true
具有 ARO、OpenShift 或 Windows 节点的已启用 Arc 的群集
使用 ARO (Azure Red Hat Openshift)、OpenShift 或 Windows 节点且已启用 Arc 的 Kubernetes 群集不支持托管标识身份验证。 通过指定 amalogs.useAADAuth=false
来使用旧式身份验证,如以下示例所示。
az k8s-extension create --name azuremonitor-containers --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings amalogs.useAADAuth=false
删除扩展实例
以下命令仅删除扩展实例,但不删除 Log Analytics 工作区。 Log Analytics 资源中的数据保持不变。
az k8s-extension delete --name azuremonitor-containers --cluster-type connectedClusters --cluster-name <cluster-name> --resource-group <resource-group>
使用 Azure 门户启用完整监视
新的 AKS 群集(Prometheus、容器见解和 Grafana)
在 Azure 门户中创建新的 AKS 群集时,会在“监视”选项卡中选中“启用容器日志”、“启用 Prometheus 指标”、“启用 Grafana”和“启用建议的警报”复选框。
现有群集(Prometheus、容器见解和 Grafana)
- 请在 Azure 门户中进入您的集群。
- 在服务菜单中,选择“ 监视>监视器设置”。
- 已为你选择 Prometheus 指标、Grafana 和容器日志及事件。 如果你现在有 Azure Monitor 工作区、Grafana 工作区和 Log Analytics 工作区,系统会为你选择它们。
- 如果你希望选择备用工作区或创建新工作区,请选择“高级设置”。 使用“日志记录配置文件和经典配置文件”设置,你可以修改默认集合详细信息来降低监视成本。 有关详细信息,请参阅在容器见解中启用成本优化设置。
- 选择“配置” 。
启用 Windows 指标收集(预览)
注意
windows-exporter-daemonset.yaml 中不存在 CPU/内存限制,因此可能会过度预配 Windows 节点
有关更多详细信息,请参阅资源预留
在部署工作负载时,请对容器设置资源内存和 CPU 限制。 这也会从 NodeAllocatable 中扣减,并且可以帮助群集范围的计划程序确定将哪些 pod 放置在哪些节点上。 在没有限制的情况下调度 pod 可能会导致 Windows 节点过度预配,在极端情况下可能会导致节点运行不正常。
自托管 Prometheus 加载项容器 (prometheus_collector) 的 6.4.0-main-02-22-2023-3ee44b9e 版本起,AKS 群集已启用 Windows 指标收集。 加入 Azure Monitor 指标附加组件可使 Windows 守护进程集 pod 在节点池上开始运行。 支持 Windows Server 2019 和 Windows Server 2022。 按照以下步骤使 Pod 能够从 Windows 节点池收集指标。
通过部署 windows-exporter-daemonset YAML 文件,在 AKS 节点上手动安装 windows 导出程序以访问 Windows 指标。 启用以下收集器:
[defaults]
container
memory
process
cpu_info
有关更多收集器,请参阅适用于 Windows 指标的 Prometheus 导出器。
部署 windows-exporter-daemonset YAML 文件。 请注意,如果在节点上应用了任何排斥,你将需要应用相应的容忍度。
kubectl apply -f windows-exporter-daemonset.yaml
将 ama-metrics-settings-configmap 应用到群集。 将
windowsexporter
和windowskubeproxy
布尔值设置为true
。 有关详细信息,请参阅指标加载项设置 configmap。启用开箱即用仪表板所需的录制规则:
[仅适用于已启用 ARC 的群集中的 Windows 节点]如果要为已启用 ARC 的群集启用托管 Prometheus,则可以配置群集中 Linux 节点上运行的 Managed Prometheus,以从 Windows 节点上运行的终结点中抓取指标。 将以下抓取任务添加到 ama-metrics-prometheus-config-configmap.yaml,并将 configmap 应用到集群。
scrape_configs:
- job_name: windows-exporter
scheme: http
scrape_interval: 30s
label_limit: 63
label_name_length_limit: 511
label_value_length_limit: 1023
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_name]
target_label: instance
- action: keep
source_labels: [__meta_kubernetes_node_label_kubernetes_io_os]
regex: windows
- source_labels:
- __address__
action: replace
target_label: __address__
regex: (.+?)(\:\d+)?
replacement: $$1:9182
kubectl apply -f ama-metrics-prometheus-config-configmap.yaml
验证部署
使用 kubectl 命令行工具验证是否已正确部署代理。
托管 Prometheus
验证是否已在 Linux 节点池上正确部署 DaemonSet
kubectl get ds ama-metrics-node --namespace=kube-system
Pod 数应等于群集上的 Linux 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-metrics-node --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-metrics-node 1 1 1 1 1 <none> 10h
验证是否已正确部署 Windows 节点
kubectl get ds ama-metrics-win-node --namespace=kube-system
Pod 数应等于群集上的 Windows 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-metrics-node --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-metrics-win-node 3 3 3 3 3 <none> 10h
验证是否为 Prometheus 部署了两个 ReplicaSet
kubectl get rs --namespace=kube-system
输出应与下面的示例类似:
User@aksuser:~$kubectl get rs --namespace=kube-system
NAME DESIRED CURRENT READY AGE
ama-metrics-5c974985b8 1 1 1 11h
ama-metrics-ksm-5fcf8dffcd 1 1 1 11h
容器见解
验证是否已在 Linux 节点池上正确部署 DaemonSet
kubectl get ds ama-logs --namespace=kube-system
Pod 数应等于群集上的 Linux 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-logs --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-logs 2 2 2 2 2 <none> 1d
验证是否已正确部署 Windows 节点
kubectl get ds ama-logs-windows --namespace=kube-system
Pod 数应等于群集上的 Windows 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-logs-windows --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-logs-windows 2 2 2 2 2 <none> 1d
验证容器见解解决方案的部署
kubectl get deployment ama-logs-rs --namespace=kube-system
输出应与下面的示例类似:
User@aksuser:~$ kubectl get deployment ama-logs-rs --namespace=kube-system
NAME READY UP-TO-DATE AVAILABLE AGE
ama-logs-rs 1/1 1 1 24d
使用 CLI 查看配置
使用 aks show
命令查看是否已启用解决方案,并查看 Log Analytics 工作区资源 ID 以及有关群集的摘要信息。
az aks show --resource-group <resourceGroupofAKSCluster> --name <nameofAksCluster>
该命令将会返回有关解决方案的 JSON 格式信息。 addonProfiles
部分应包括有关 omsagent
的信息,如下例所示:
"addonProfiles": {
"omsagent": {
"config": {
"logAnalyticsWorkspaceResourceID": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace",
"useAADAuth": "true"
},
"enabled": true,
"identity": null
},
}
预配的资源
启用监视时,会在你的订阅中创建以下资源:
资源名称 | 资源类型 | 资源组 | 区域/位置 | 说明 |
---|---|---|---|---|
MSCI-<aksclusterregion>-<clustername> |
数据收集规则 | 与群集相同 | 与 Log Analytics 工作区相同 | 此数据收集规则适用于 Azure Monitor 代理的日志收集,该代理使用 Log Analytics 工作区作为目标,并关联到 AKS 群集资源。 |
MSPROM-<aksclusterregion>-<clustername> |
数据收集规则 | 与群集相同 | 与 Azure Monitor 工作区相同 | 此数据收集规则用于通过指标插件收集 Prometheus 指标,将所选的 Azure Monitor 工作区作为目标,并且还关联到 AKS 集群资源。 |
MSPROM-<aksclusterregion>-<clustername> |
数据收集终结点 | 与群集相同 | 与 Azure Monitor 工作区相同 | 上述数据收集规则使用此数据收集终结点从指标加载项引入 Prometheus 指标 |
新建 Azure Monitor 工作区时,会创建以下附加资源作为工作区的一部分
资源名称 | 资源类型 | 资源组 | 区域/位置 | 说明 |
---|---|---|---|---|
<azuremonitor-workspace-name> |
数据收集规则 | MA_<azuremonitor-workspace-name>_<azuremonitor-workspace-region>_managed | 与 Azure Monitor 工作区相同 | 使用 OSS Prometheus 服务器远程写入 Azure Monitor 工作区时创建的 DCR。 |
<azuremonitor-workspace-name> |
数据收集终结点 | MA_<azuremonitor-workspace-name>_<azuremonitor-workspace-region>_managed | 与 Azure Monitor 工作区相同 | 使用 OSS Prometheus 服务器远程写入 Azure Monitor 工作区时创建的 DCE。 |
Windows 群集与 Linux 群集之间的差异
监视 Windows Server 群集与监视 Linux 群集相比,主要差异包括:
- Windows 没有内存 RSS 指标。 因此它不适用于 Windows 节点和容器。 工作集指标可用。
- 磁盘存储容量信息不适用于 Windows 节点。
- 仅监视 Pod 环境,不监视 Docker 环境。
- 使用预览版时,最多支持 30 个 Windows Server 容器。 此限制不适用于 Linux 容器。
注意
容器见解对 Windows Server 2022 操作系统的支持目前为预览版。
容器化 Linux 代理 (replicaset pod) 向群集内 Kubelet 安全端口 (10250) 上的所有 Windows 节点进行 API 调用,以收集与节点和容器性能相关的指标。 应在群集的虚拟网络中针对入站和出站打开 Kubelet 安全端口 (:10250),以便正常收集 Windows 节点和容器性能相关指标。
如果你有一个包含 Windows 节点的 Kubernetes 群集,请查看并配置网络安全组和网络策略,确保在群集的虚拟网络中针对入站和出站打开 Kubelet 安全端口 (:10250)。