I'm trying to get kube-apiserver prometheus metrics with kubectl
command.
I can get it from kubectl proxy
[which proxy the api in localhost:8001(by default)]. then go to http://localhost:8001/metrics
I want to get this metrics directly through kubectl
command, without proxying.
My kubernetes version
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"}
You can install helm chart present here -
https://github.com/helm/charts/tree/master/stable/prometheus-operator
It will provide you all metrics, you can run the prometheus service locally by port-forwarding and can get all metrics at its dashboard
Got the answer
$ kubectl get --raw /metrics
This command directly communicate with kube apiserver and get the prometheus metrics of kube apiserver.