本文永久链接: https://www.xtplayer.cn/prometheus/prometheus-adapter/

Prometheus 准备

从 Rancher v2.4.8-ent(监控 chart 版本 0.1.2000)开始,只能通过应用商店跳转的链接访问 Prometheus,直接通过 Pod IP 、svc 或者 Nodeport 无法访问。如果想通过 Nodeport 或者 Ingress 代理访问 Prometheus ,配置方法请访问 通过 Nodeport 或者 Ingress 访问 Prometheus

对于集群监控 chart 版本高于 0.1.4001 的环境,在集群监控配置页添加应答 prometheus.serviceNodePort = true,将会自动创建一个 Nodeport svc,通过 Nodeport 端口即可访问。

Prometheus Adapter 安装

Prometheus Adapter chart 地址:https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-adapter

  1. 将 chart 添加到 rancher 应用商店,如图:

  2. 进入 system 项目|应用商店,点击启动可用看到 Prometheus-Adapter。

Prometheus Adapter 配置

根据 Prometheus 准备 中说明的,如果你的 集群监控 chart 版本高于 0.1.2000,并且低于 0.1.4001,需要访问 通过 nodeport 或者 ingress 访问 Prometheus 去配置 Prometheus 的访问地址。如果 chart 版本高于 0.1.4001,则在集群监控配置页添加应答 prometheus.serviceNodePort = true,将会自动创建一个 Nodeport svc,通过 Nodeport 端口即可访问。

本示例中以为 ingress 代理访问 Prometheus 为例,

Prometheus Adapter 测试

最简单的只需要在命令行中执行命令 kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 ,正常情况会有很多数据输出。此处截取一小部分:

Prometheus Adapter 自定义配置

自定义配置可以参考 https://github.com/kubernetes-sigs/prometheus-adapter/tree/master/docs