我正在尝试使用kubectl
命令获取kube-apiserver的普罗米修斯指标。
我可以从kubectl proxy
[哪个代理在localhost:8001(默认情况下)代理api中获取它]]。然后转到http://localhost:8001/metrics
我想直接通过kubectl
命令获得此指标,而无需代理。
我的kubernetes版本
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.0", GitCommit:"91e7b4fd31fcd3d5f436da26c980becec37ceefe", GitTreeState:"clean", BuildDate:"2018-06-27T20:17:28Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.7-gke.24", GitCommit:"2ce02ef1754a457ba464ab87dba9090d90cf0468", GitTreeState:"clean", BuildDate:"2019-08-12T22:05:28Z", GoVersion:"go1.11.5b4", Compiler:"gc", Platform:"linux/amd64"}
得到答案
$ kubectl get --raw /metrics
此命令直接与kube apiserver通信并获取kube apiserver的prometheus指标。
您可以在此处安装头盔图表-
https://github.com/helm/charts/tree/master/stable/prometheus-operator
它将为您提供所有指标,您可以通过端口转发在本地运行prometheus服务,并可以在其仪表板上获取所有指标