Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect PodDisruptionBudget metrics #3111

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def _create_kubernetes_state_prometheus_instance(self, instance):
'kube_pod_container_resource_limits_nvidia_gpu_devices': 'container.gpu.limit',
'kube_pod_status_ready': 'pod.ready',
'kube_pod_status_scheduled': 'pod.scheduled',
'kube_poddisruptionbudget_status_current_healthy': 'pdb.pods_healthy',
'kube_poddisruptionbudget_status_desired_healthy': 'pdb.pods_desired',
'kube_poddisruptionbudget_status_pod_disruptions_allowed': 'pdb.disruptions_allowed',
'kube_poddisruptionbudget_status_expected_pods': 'pdb.pods',
'kube_replicaset_spec_replicas': 'replicaset.replicas_desired',
'kube_replicaset_status_fully_labeled_replicas': 'replicaset.fully_labeled_replicas',
'kube_replicaset_status_ready_replicas': 'replicaset.replicas_ready',
Expand Down Expand Up @@ -196,6 +200,7 @@ def _create_kubernetes_state_prometheus_instance(self, instance):
'kube_pod_owner',
'kube_pod_start_time',
'kube_pod_labels',
'kube_poddisruptionbudget_created',
'kube_replicaset_created',
'kube_replicationcontroller_created',
'kube_resourcequota_created',
Expand Down
4 changes: 4 additions & 0 deletions kubernetes_state/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ kubernetes_state.nodes.by_condition,gauge,,,,To sum by `condition` and `status`
kubernetes_state.hpa.min_replicas,gauge,,,,Lower limit for the number of pods that can be set by the autoscaler,0,kubernetes,k8s_state.hpa.min_replicas
kubernetes_state.hpa.max_replicas,gauge,,,,Upper limit for the number of pods that can be set by the autoscaler,0,kubernetes,k8s_state.hpa.max_replicas
kubernetes_state.hpa.desired_replicas,gauge,,,,Desired number of replicas of pods managed by this autoscaler,0,kubernetes,k8s_state.hpa.desired_replicas
kubernetes_state.pdb.pods_desired,gauge,,,,Minimum desired number of healthy pods,0,kubernetes,k8s_state.pdb.pods_desired
kubernetes_state.pdb.disruptions_allowed,gauge,,,,Number of pod disruptions that are currently allowed,0,kubernetes,k8s_state.pdb.disruptions_allowed
kubernetes_state.pdb.pods_healthy,gauge,,,,Current number of healthy pods,0,kubernetes,k8s_state.pdb.pods_healthy
xvello marked this conversation as resolved.
Show resolved Hide resolved
kubernetes_state.pdb.pods,gauge,,,,Total number of pods counted by this disruption budget,0,kubernetes,k8s_state.pdb.pods
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to rename it .pdb.pods_total for consistency with the other gauges, and being more explicit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur as it would also be consistent with what one sees when using kubectl describe pdb ....

kubernetes_state.pod.ready,gauge,,,,"In association with the `condition` tag, whether the pod is ready to serve requests, e.g. `condition:true` keeps the pods that are in a ready state",1,kubernetes,k8s_state.pod.ready
kubernetes_state.pod.scheduled,gauge,,,,Reports the status of the scheduling process for the pod with its tags,0,kubernetes,k8s_state.pod.scheduled
kubernetes_state.pod.status_phase,gauge,,,,"To sum by `phase` to get number of pods in a given phase, and `namespace` to break this down by namespace",0,kubernetes,k8s_state.pod.status_phase
Expand Down
12 changes: 12 additions & 0 deletions kubernetes_state/tests/fixtures/prometheus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,18 @@ kube_pod_status_scheduled{condition="unknown",namespace="kube-system",pod="kube-
kube_pod_status_scheduled{condition="unknown",namespace="kube-system",pod="kubernetes-dashboard-zhtjl"} 0
kube_pod_status_scheduled{condition="unknown",namespace="kube-system",pod="registry-creds-hq249"} 0
kube_pod_status_scheduled{condition="unknown",namespace="kube-system",pod="tiller-deploy-1651615695-dcphn"} 0
# HELP kube_poddisruptionbudget_status_current_healthy Current number of healthy pods
# TYPE kube_poddisruptionbudget_status_current_healthy gauge
kube_poddisruptionbudget_status_current_healthy{namespace="default",poddisruptionbudget="web-pdb"} 3
# HELP kube_poddisruptionbudget_status_desired_healthy Minimum desired number of healthy pods
# TYPE kube_poddisruptionbudget_status_desired_healthy gauge
kube_poddisruptionbudget_status_desired_healthy{namespace="default",poddisruptionbudget="web-pdb"} 2
# HELP kube_poddisruptionbudget_status_pod_disruptions_allowed Number of pod disruptions that are currently allowed
# TYPE kube_poddisruptionbudget_status_pod_disruptions_allowed gauge
kube_poddisruptionbudget_status_pod_disruptions_allowed{namespace="default",poddisruptionbudget="web-pdb"} 1
# HELP kube_poddisruptionbudget_status_expected_pods Total number of pods counted by this disruption budget
# TYPE kube_poddisruptionbudget_status_expected_pods gauge
kube_poddisruptionbudget_status_expected_pods{namespace="default",poddisruptionbudget="web-pdb"} 3
# HELP kube_replicaset_created Unix creation timestamp
# TYPE kube_replicaset_created gauge
kube_replicaset_created{namespace="default",replicaset="failingtest-f585bbd4"} 1.510059371e+09
Expand Down
5 changes: 5 additions & 0 deletions kubernetes_state/tests/test_kubernetes_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
NAMESPACE + '.hpa.max_replicas',
NAMESPACE + '.hpa.desired_replicas',
NAMESPACE + '.hpa.current_replicas',
# pdb
NAMESPACE + '.pdb.disruptions_allowed',
NAMESPACE + '.pdb.pods',
NAMESPACE + '.pdb.pods_desired',
NAMESPACE + '.pdb.pods_healthy',
# pods
NAMESPACE + '.pod.ready',
NAMESPACE + '.pod.scheduled',
Expand Down