Search code examples
kubernetesmetricshorizontal-pod-autoscaling

How to View/Debug Kubernetes Custom Metric Values (custom.metrics.k8s.io)?


I am using this to export metrics from Prometheus to Kubernetes. That seems to be working. I can (successfully) see the metric names with

kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 | jq '.'

This shows the names of the metrics, but doesn't show the values. How do I see the values?

I intend to use this with a HorizontalPodAutoscaler. I'd like to see what the metric values look like within the Kubernetes Metric System to assist in understanding and configuring this correctly.


Solution

  • You need to be more specific for the Kubernetes API.

    If you deployed everything correctly and everything is working as it should when you use

    $ kubectl get --raw="/apis/custom.metrics.k8s.io/v1beta1" | jq
    

    you should get list of MetricValues if you have any metrics added.

    Here is a really good article about Building Kubernetes Apps with Scaling on Custom Metrics: A Gentle Introduction.

    You mentioned that your intend is to use the metrics for HorizontalPodAutoscaler, I would strongly recommend going over Kubernetes pod autoscaler using custom metrics as it provides some really nice examples on how to create and use custom metrics.