0
votes

We are having a Kubernetes cluster and using Prometheus + Grafana for monitoring and alerting. We need to show a panel on Grafana that shows us the view (same as kubectl get namespaces) . Currently we are able to get name and status column using the below PROMQL along with Hide options in Visualization section of Grafana.

count(kube_namespace_status_phase) by (phase, namespace)

But we also want to find the AGE from when a namespace was active/created. We are not able to find AGE in any of the 4 kube metrics of namespace available -

  1. kube_namespace_created
  2. kube_namespace_status_phase
  3. kube_namespace_lables
  4. kube_namespace_annotations

Any suggestions would be helpful.

2

2 Answers

0
votes

Unfortunately as you already noticed there is no specific metric that could be used to calculate the age of an object. The closest thing that you could use to achieve your goal would be to use kube_namespace_created which shows at what time namespace in Kubernetes was created.

I was also not able to find a proper Prometheus operator/function in order to make some kind of workaround PROMQL.

I am posting this answer as a community wiki. Feel free to expand on it as you wish.

I hope it helps.

0
votes

I have seen on other metrics regarding age that you need to multiply by 1000

So if you do;

kube_namespace_created * 1000

You would need to check/test but I've seen that used on other queries about finding the age of worker nodes.