How Kubernetes Provides Metrics
Kubernetes provides a /metrics
URI on the API server. This API requires an authorized token to be able to access it. To access this endpoint, let’s create a ServiceAccount
, ClusterRole
, and ClusterRoleBinding
:
$ kubectl create sa getmetrics
$ kubectl create clusterrole get-metrics --non-resource-url=/metrics --verb=get
$ kubectl create clusterrolebinding get-metrics --clusterrole=get-metrics --serviceaccount=default:getmetrics
$ export TOKEN=$(kubectl create token getmetrics -n default)
$ curl -v --insecure -H "Authorization: Bearer $TOKEN" https://0.0.0.0:6443/metrics
# HELP aggregator_discovery_aggregation_count_total [ALPHA] Counter of number of times discovery was aggregated
.
.
.
This is going to take a while; there are too many metrics that are collected to document here. We’ll talk about some individual metrics after we get some context on how the metrics are created and consumed by Prometheus. The main point...