Skip to content

Commit

Permalink
Collect .hpa.status gauges (#3107)
Browse files Browse the repository at this point in the history
  • Loading branch information
xvello authored Feb 15, 2019
1 parent 5fdbb5a commit 3011114
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def _create_kubernetes_state_prometheus_instance(self, instance):
'kube_hpa_spec_max_replicas': 'hpa.max_replicas',
'kube_hpa_status_desired_replicas': 'hpa.desired_replicas',
'kube_hpa_status_current_replicas': 'hpa.current_replicas',
'kube_hpa_status_condition': 'hpa.condition',
'kube_node_status_allocatable_cpu_cores': 'node.cpu_allocatable',
'kube_node_status_allocatable_memory_bytes': 'node.memory_allocatable',
'kube_node_status_allocatable_pods': 'node.pods_allocatable',
Expand Down
1 change: 1 addition & 0 deletions kubernetes_state/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ 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.hpa.condition,gauge,,,,Observed condition of autoscalers to sum by condition and status,0,kubernetes,k8s_state.hpa.status
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
Expand Down
11 changes: 11 additions & 0 deletions kubernetes_state/tests/fixtures/prometheus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -863,3 +863,14 @@ kube_limitrange{constraint="defaultRequest",limitrange="limits",namespace="defau
kube_daemonset_updated_number_scheduled{namespace="kube-system",daemonset="kube-proxy"} 3
kube_daemonset_updated_number_scheduled{namespace="kube-system",daemonset="kube-svc-redirect"} 3
kube_daemonset_updated_number_scheduled{namespace="default",daemonset="dd-datadog"} 3
# HELP kube_hpa_status_condition The condition of this autoscaler.
# TYPE kube_hpa_status_condition gauge
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="true",status="AbleToScale"} 1
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="false",status="AbleToScale"} 0
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="unknown",status="AbleToScale"} 0
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="true",status="ScalingActive"} 0
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="false",status="ScalingActive"} 1
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="unknown",status="ScalingActive"} 0
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="true",status="ScalingLimited"} 1
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="false",status="ScalingLimited"} 0
kube_hpa_status_condition{namespace="default",hpa="myhpa",condition="unknown",status="ScalingLimited"} 0
7 changes: 7 additions & 0 deletions kubernetes_state/tests/test_kubernetes_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
NAMESPACE + '.hpa.max_replicas',
NAMESPACE + '.hpa.desired_replicas',
NAMESPACE + '.hpa.current_replicas',
NAMESPACE + '.hpa.condition',
# pdb
NAMESPACE + '.pdb.disruptions_allowed',
NAMESPACE + '.pdb.pods_desired',
Expand Down Expand Up @@ -148,6 +149,12 @@
'job:hello',
'job_name:hello2',
],
NAMESPACE + '.hpa.condition': [
'namespace:default',
'hpa:myhpa',
'condition:true',
'status:AbleToScale',
],
}

JOINED_METRICS = {
Expand Down

0 comments on commit 3011114

Please sign in to comment.