添加prometheus-community到repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
更新repo
helm repo update
创建命名空间
kubectl create ns prometheus-stack
安装
helm -n prometheus-stack install kube-prometheus-stack prometheus-community/kube-prometheus-stack
安装完成效果如下图:
什么是服务发现?
我们在每个节点上面都运行了 node-exporter,如果我们通过一个 Service 来将数据收集到一起用静态配置的方式配置到 Prometheus 去中,就只会显示一条数据,我们得自己在指标数据中去过滤每个节点的数据,当然我们也可以手动的把所有节点用静态的方式配置到 Prometheus 中去,但是以后要新增或者去掉节点的时候就还得手动去配置,那么有没有一种方式可以让 Prometheus 去自动发现我们节点的 node-exporter 程序,并且按节点进行分组呢?这就是 Prometheus 里面非常重要的「服务发现」功能。
配置参考链接:https://prometheus.io/docs/prometheus/latest/configuration/configuration/
创建自动发现规则
我们定义的 Prometheus 的配置如下 prometheus-a