帮助改进此页面
要帮助改进本用户指南,请选择位于每个页面右侧窗格中的在 GitHub 上编辑此页面链接。
使用 Helm 部署 Prometheus
您可以使用 Helm V3 将 Prometheus 部署到集群中,而不使用 Amazon Managed Service for Prometheus。如果您已安装有 Helm,则可使用 helm version
命令来检查您的版本。Helm 是 Kubernetes 集群的包管理器。有关 Helm 及其安装方法的更多信息,请参阅 使用 Helm 在 Amazon EKS 上部署应用程序。
在为您的 Amazon EKS 集群配置 Helm 后,您可以使用它来部署 Prometheus,步骤如下。
-
创建 Prometheus 命名空间。
kubectl create namespace prometheus
-
添加
prometheus-community
图表存储库。helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
-
部署 Prometheus。
helm upgrade -i prometheus prometheus-community/prometheus \ --namespace prometheus \ --set alertmanager.persistence.storageClass="gp2" \ --set server.persistentVolume.storageClass="gp2"
注意
如果您在执行此命令时收到错误
Error: failed to download "stable/prometheus" (hint: running helm repo update may help)
,请运行helm repo update prometheus-community
,然后尝试再次运行第 2 步命令。如果您收到错误
Error: rendered manifests contain a resource that already exists
,请运行helm uninstall
,然后尝试再次运行第 3 步命令。your-release-name
-nnamespace
-
确认
prometheus
命名空间中的所有容器组(pod)均处于READY
状态。kubectl get pods -n prometheus
示例输出如下。
NAME READY STATUS RESTARTS AGE prometheus-alertmanager-59b4c8c744-r7bgp 1/2 Running 0 48s prometheus-kube-state-metrics-7cfd87cf99-jkz2f 1/1 Running 0 48s prometheus-node-exporter-jcjqz 1/1 Running 0 48s prometheus-node-exporter-jxv2h 1/1 Running 0 48s prometheus-node-exporter-vbdks 1/1 Running 0 48s prometheus-pushgateway-76c444b68c-82tnw 1/1 Running 0 48s prometheus-server-775957f748-mmht9 1/2 Running 0 48s
-
使用
kubectl
将 Prometheus 控制台端口转发到本地计算机。kubectl --namespace=prometheus port-forward deploy/prometheus-server 9090
-
在 Web 浏览器中打开
http://localhost:9090
来查看 Prometheus 控制台。 -
从 - insert metric at cursor (- 在光标位置插入指标) 菜单选择一个指标,然后选择 Execute (执行)。选择 Graph (图表) 选项卡显示一段时间内的指标。下图显示了一段时间内的
container_memory_usage_bytes
。 -
在顶部导航栏中,选择 Status (状态),然后选择 Targets (目标)。
使用服务发现连接到 Prometheus 的所有 Kubernetes 终端节点将显示。