1
votes

I am trying to develop dashboards on Grafana that tells the status of different pods with the help of kube labels. Eg: I am able to get the restarts using this label: kube_deployment_status_observed_generation

What i want is the age, For a deployment we can get the age on kuberenetes cluster using, kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE deployemnt-test-state 1/1 1 1 6d2h

I want this same age to be shown in Grafana but I am not able to find this “age” anywhere in any label.

Can anyone help me where and how i can get these variables.

1

1 Answers

0
votes

If you are speaking about object creation time metrics kube-state-metrics exposes a creation time for almost all the objects it tracks. The metric name follows the pattern kube_<OBJECT>_created and will include values for the name of the object and the namespace where it lives. The value is an epoch timestamp to the millisecond.

For example, the CronJob creation series is called kube_cronjob_created.

To calculate the average age of all CronJobs running use this query:

avg(time() - kube_cronjob_created ).

In your case you can use metrics kube_deployment_created to check the age of deployment.

More information you can find here: kube-state-metrics.