在 Azure Stack Hub 上使用用于容器的 Azure MonitorUse Azure Monitor for containers on Azure Stack Hub

可以使用用于容器的 Azure Monitor 来监视在 Azure Stack Hub 中通过 AKS 引擎部署的 Kubernetes 群集中的容器。You can use Azure Monitor for containers to monitor your containers in an AKS engine deployed Kubernetes cluster in Azure Stack Hub.

重要

Azure Stack Hub 上用于容器的 Azure Monitor 当前为公共预览版。Azure Monitor for containers on Azure Stack Hub is currently in public preview. 此预览版在提供时没有附带服务级别协议,不建议将其用于生产工作负荷。This preview version is provided without a service level agreement, and it's not recommended for production workloads. 某些功能可能不受支持或者受限。Certain features might not be supported or might have constrained capabilities.

可以通过指标 API 从 Kubernetes 中可用的控制器、节点和容器中收集内存和处理器指标,从而使用 Azure Monitor 查看容器性能。You can review container performance with Azure Monitor by collecting memory and processor metrics from controllers, nodes, and containers available in Kubernetes through the Metrics API. 此外,该服务还会收集容器日志。In addition, the service collects container logs. 可以使用这些日志诊断 Azure 的本地群集中的问题。You can use these logs to diagnose issues in your on-premises cluster from Azure. 从 Kubernetes 群集设置监视后,将自动收集这些指标和日志。After you set up monitoring from your Kubernetes clusters, these metrics and logs are automatically gathered. 适用于 Linux 的 Azure Monitor Log Analytics 代理的容器化版本会收集日志。A containerized version of the Azure Monitor Log Analytics agent for Linux gathers the logs. Azure Monitor 将指标和日志存储在 Azure 订阅的可供访问的 Log Analytics 工作区中。Azure Monitor stores the metrics and logs in your log analytics workspace accessible in your Azure subscription.

可通过两种方式在群集上启用 Azure Monitor。There are two ways to enable Azure Monitor on your cluster. 这两种方式都需要在 Azure 中设置 Azure Monitor Log Analytics 工作区。Both ways require you to set up an Azure Monitor Log Analytics workspace in Azure.

先决条件Prerequisites

这两种方法都需要符合 Azure Monitor - 容器中列出的先决条件Both methods require the pre-requisites listed in the Azure Monitor – Containers.

方法一Method one

还可以使用 Helm 图表在群集中安装监视代理。You can also use the Helm chart to install the monitoring agents in your cluster. 请按照 Azure Monitor - 容器一文中的说明操作。Follow the instructions in the following article, Azure Monitor – Containers.

方法二Method two

你可以在 AKS 引擎群集规范 json 文件中指定一个加载项****。You can specify an addon in the AKS engine cluster specification json file. 该文件也称为“API 模型”。The file is also called the API Model. 此加载项中提供用于存储监视信息的 Azure Log Analytics 工作区的 WorkspaceGUID**** 和 WorkspaceKey**** 的 base64 编码版本。In this addon, provide the base64 encoded version of WorkspaceGUID and WorkspaceKey of the Azure Log Analytics Workspace where the monitoring information will be stored.

在此示例中可以找到 Azure Stack Hub 群集支持的 API 定义:kubernetes-container-monitoring_existing_workspace_id_and_key.jsonSupported API definitions for the Azure Stack Hub cluster can be found in this example: kubernetes-container-monitoring_existing_workspace_id_and_key.json. 具体而言,请在 kubernetesConfig 中查找 addons 属性:Specifically, find the addons property in kubernetesConfig:

 "orchestratorType": "Kubernetes",
       "kubernetesConfig": {
         "addons": [
           {
             "name": "container-monitoring",
             "enabled": true,
             "config": {
               "workspaceGuid": "<Azure Log Analytics Workspace Guid in Base-64 encoded>",
               "workspaceKey": "<Azure Log Analytics Workspace Key in Base-64 encoded>"
             }
           }
         ]
       }

后续步骤Next steps