Search code examples
kuberneteskube-state-metrics

What does _condition_ mean in metric?


In kube-state-metrics there is a metric for pods - kube_pod_status_ready that has 3 attributes

pod=<pod-name>  
namespace=<pod-namespace> 
condition=<true|false|unknown>

What does condition attribute stand for? I can't find it's definition anywhere in the docs. I can guess what it means, but it would be great to get a definition or explanation of how it's calculated.


Solution

  • That's documented in the API reference. In essence it's the condition in the status field for "type": "Ready" for a given pod. For example in the following output:

    $ kubectl get pod <your-pod> -o=json | jq .status.conditions
    [
      ...
      {
        "lastProbeTime": null,
        "lastTransitionTime": "2018-11-20T22:45:27Z",
        "status": "True",
        "type": "Ready"
      },
      ...
    ]
    

    In this case, the sub-field "status": "True" represents condition=true in your metrics. Alternatively, "status": "False" would represent condition=false and "status": "Unknown" would represent condition=unknown.