Calculate the availability of a pod in kubernetes over a period of time

1/17/2020

I need to calculate the availability of a pod in kubernetes over a period of time in percentage using PromQL. Any suggestions are welcome.

-- Mukund Sharma
grafana
kubernetes
prometheus
promql

1 Answer

1/18/2020

I was able to achieve it with below query:

(sum_over_time((sum(kube_pod_status_ready{cluster="$cluster",condition="true", namespace="$namespace"}))[$availability_span:5m])) / (sum_over_time((sum(kube_pod_status_ready{cluster="$cluster",namespace="$namespace"}))[$availability_span:5m])) * 100

-- Mukund Sharma
Source: StackOverflow