diff --git a/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py b/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py index 1143f39f1b42b..aa1e205b00903 100644 --- a/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py +++ b/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py @@ -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_total', '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', @@ -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', diff --git a/kubernetes_state/metadata.csv b/kubernetes_state/metadata.csv index b0d868db7ccc5..04c86339b8de3 100644 --- a/kubernetes_state/metadata.csv +++ b/kubernetes_state/metadata.csv @@ -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,1,kubernetes,k8s_state.pdb.pods_healthy +kubernetes_state.pdb.pods_total,gauge,,,,Total number of pods counted by this disruption budget,0,kubernetes,k8s_state.pdb.pods_total 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 diff --git a/kubernetes_state/tests/fixtures/prometheus.txt b/kubernetes_state/tests/fixtures/prometheus.txt index 75adc2498c192..f8f681f06046d 100644 --- a/kubernetes_state/tests/fixtures/prometheus.txt +++ b/kubernetes_state/tests/fixtures/prometheus.txt @@ -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 diff --git a/kubernetes_state/tests/test_kubernetes_state.py b/kubernetes_state/tests/test_kubernetes_state.py index 466dcdf6a9732..9a09af35fbd7b 100644 --- a/kubernetes_state/tests/test_kubernetes_state.py +++ b/kubernetes_state/tests/test_kubernetes_state.py @@ -47,6 +47,11 @@ NAMESPACE + '.hpa.max_replicas', NAMESPACE + '.hpa.desired_replicas', NAMESPACE + '.hpa.current_replicas', + # pdb + NAMESPACE + '.pdb.disruptions_allowed', + NAMESPACE + '.pdb.pods_desired', + NAMESPACE + '.pdb.pods_healthy', + NAMESPACE + '.pdb.pods_total', # pods NAMESPACE + '.pod.ready', NAMESPACE + '.pod.scheduled',