diff --git a/kubernetes_state/CHANGELOG.md b/kubernetes_state/CHANGELOG.md index beac2b950b7d7..2923bdf678466 100644 --- a/kubernetes_state/CHANGELOG.md +++ b/kubernetes_state/CHANGELOG.md @@ -1,19 +1,11 @@ # CHANGELOG - kubernetes_state -1.3.1 / 2017-10-12 -================== -* [] Adding HPA metrics 1.4.0 / Unreleased ================== ### Changes * [UPDATE] Update auto_conf template to support agent 6 and 5.20+. See [#860][] - -1.4.0 / Unreleased -================== - -### Changes - +* [FEATURE] Adding HPA metrics. See [#801][] * [FEATURE] Add metrics for GPU, PVC, CronJobs and other added in kubernetes_state 1.1.0. See [#853][] 1.3.0 / 2017-08-28 diff --git a/kubernetes_state/check.py b/kubernetes_state/check.py index 81c869ecb2bbb..ce3aed02a70c7 100644 --- a/kubernetes_state/check.py +++ b/kubernetes_state/check.py @@ -132,6 +132,7 @@ def __init__(self, name, init_config, agentConfig, instances=None): 'kube_replicationcontroller_status_observed_generation', 'kube_statefulset_metadata_generation', 'kube_statefulset_status_observed_generation', + 'kube_hpa_metadata_generation', # kube_node_status_phase and kube_namespace_status_phase have no use case as a service check 'kube_namespace_status_phase', 'kube_node_status_phase', diff --git a/kubernetes_state/ci/fixtures/prometheus/prometheus.txt b/kubernetes_state/ci/fixtures/prometheus/prometheus.txt index 062d945575087..05d5bb4775729 100644 --- a/kubernetes_state/ci/fixtures/prometheus/prometheus.txt +++ b/kubernetes_state/ci/fixtures/prometheus/prometheus.txt @@ -1,3 +1,18 @@ +# HELP kube_hpa_metadata_generation The generation observed by the HorizontalPodAutoscaler controller. +# TYPE kube_hpa_metadata_generation gauge +kube_hpa_metadata_generation{hpa="hpa1",namespace="ns1"} 2 +# HELP kube_hpa_spec_max_replicas Upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas. +# TYPE kube_hpa_spec_max_replicas gauge +kube_hpa_spec_max_replicas{hpa="hpa1",namespace="ns1"} 4 +# HELP kube_hpa_spec_min_replicas Lower limit for the number of pods that can be set by the autoscaler, default 1. +# TYPE kube_hpa_spec_min_replicas gauge +kube_hpa_spec_min_replicas{hpa="hpa1",namespace="ns1"} 2 +# HELP kube_hpa_status_current_replicas Current number of replicas of pods managed by this autoscaler. +# TYPE kube_hpa_status_current_replicas gauge +kube_hpa_status_current_replicas{hpa="hpa1",namespace="ns1"} 2 +# HELP kube_hpa_status_desired_replicas Desired number of replicas of pods managed by this autoscaler. +# TYPE kube_hpa_status_desired_replicas gauge +kube_hpa_status_desired_replicas{hpa="hpa1",namespace="ns1"} 2 # HELP kube_cronjob_created Unix creation timestamp # TYPE kube_cronjob_created gauge kube_cronjob_created{cronjob="hello",namespace="default"} 1.509978394e+09 @@ -228,6 +243,9 @@ kube_node_status_condition{condition="OutOfDisk",node="minikube",status="unknown kube_node_status_condition{condition="Ready",node="minikube",status="false"} 0 kube_node_status_condition{condition="Ready",node="minikube",status="true"} 1 kube_node_status_condition{condition="Ready",node="minikube",status="unknown"} 0 +# HELP kube_node_status_network_unavailable Whether the network is correctly configured for the node. +# TYPE kube_node_status_network_unavailable gauge +kube_node_status_network_unavailable{node="127.0.0.1",condition="false"} 1 # HELP kube_persistentvolumeclaim_info Information about persistent volume claim. # TYPE kube_persistentvolumeclaim_info gauge kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="task-pv-claim",storageclass="manual"} 1 @@ -747,4 +765,4 @@ kube_service_labels{label_component="apiserver",label_provider="kubernetes",name kube_service_labels{label_app="helm",label_name="tiller",namespace="kube-system",service="tiller-deploy"} 1 kube_service_labels{label_addonmanager_kubernetes_io_mode="Reconcile",label_k8s_app="kube-dns",label_kubernetes_io_name="KubeDNS",namespace="kube-system",service="kube-dns"} 1 kube_service_labels{label_addonmanager_kubernetes_io_mode="Reconcile",label_app="kubernetes-dashboard",label_kubernetes_io_minikube_addons="dashboard",label_kubernetes_io_minikube_addons_endpoint="dashboard",namespace="kube-system",service="kubernetes-dashboard"} 1 -kube_service_labels{label_app="kube-state-metrics",label_chart="kube-state-metrics-0.3.1",label_heritage="Tiller",label_release="jaundiced-numbat",namespace="default",service="jaundiced-numbat-kube-state-metrics"} 1 +kube_service_labels{label_app="kube-state-metrics",label_chart="kube-state-metrics-0.3.1",label_heritage="Tiller",label_release="jaundiced-numbat",namespace="default",service="jaundiced-numbat-kube-state-metrics"} 1 \ No newline at end of file diff --git a/kubernetes_state/ci/fixtures/prometheus/protobuf1.x.x.bin b/kubernetes_state/ci/fixtures/prometheus/protobuf1.x.x.bin deleted file mode 100644 index 3a1cd7cd773ba..0000000000000 Binary files a/kubernetes_state/ci/fixtures/prometheus/protobuf1.x.x.bin and /dev/null differ diff --git a/kubernetes_state/test_kubernetes_state.py b/kubernetes_state/test_kubernetes_state.py index 6ced9e2d7ef4c..3d445a482bb5d 100644 --- a/kubernetes_state/test_kubernetes_state.py +++ b/kubernetes_state/test_kubernetes_state.py @@ -10,7 +10,6 @@ from tests.checks.common import AgentCheckTest NAMESPACE = 'kubernetes_state' - class TestKubernetesState(AgentCheckTest): CHECK_NAME = 'kubernetes_state' @@ -118,9 +117,9 @@ def test__update_kube_state_metrics(self, mock_poll): @mock.patch('checks.prometheus_check.PrometheusCheck.poll') def test__update_kube_state_metrics_v040(self, mock_poll): - f_name = os.path.join(os.path.dirname(__file__), 'ci', 'fixtures', 'prometheus', 'protobuf.bin') + f_name = os.path.join(os.path.dirname(__file__), 'ci', 'fixtures', 'prometheus', 'prometheus.txt') with open(f_name, 'rb') as f: - mock_poll.return_value = ('application/vnd.google.protobuf', f.read()) + mock_poll.return_value = ('text/plain', f.read()) config = { 'instances': [{