Skip to content

Commit

Permalink
Remap value 'unknown' to 'warning' for KSM 'node.ready' service check (
Browse files Browse the repository at this point in the history
…#11132)

* Remap 'unknown' to 'warning' for KSM 'node.ready' service check
  • Loading branch information
kaitlavs authored Jan 27, 2022
1 parent bdc70a4 commit e5ccc64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, name, init_config, instances):
generic_instances = [kubernetes_state_instance]
super(KubernetesState, self).__init__(name, init_config, instances=generic_instances)

self.condition_to_status_positive = {'true': self.OK, 'false': self.CRITICAL, 'unknown': self.UNKNOWN}
self.condition_to_status_positive = {'true': self.OK, 'false': self.CRITICAL, 'unknown': self.WARNING}

self.condition_to_status_negative = {'true': self.CRITICAL, 'false': self.OK, 'unknown': self.UNKNOWN}

Expand Down
1 change: 1 addition & 0 deletions kubernetes_state/tests/fixtures/prometheus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ 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
kube_node_status_condition{condition="Ready",node="test-test-node",status="unknown"} 1
# 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
Expand Down
11 changes: 7 additions & 4 deletions kubernetes_state/tests/test_kubernetes_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ def test_update_kube_state_metrics(aggregator, instance, check):
check.check(instance)

aggregator.assert_service_check(NAMESPACE + '.node.ready', check.OK)
aggregator.assert_service_check(
NAMESPACE + '.node.ready', check.WARNING, tags=['node:test-test-node', 'optional:tag1']
)
aggregator.assert_service_check(NAMESPACE + '.node.out_of_disk', check.OK)
aggregator.assert_service_check(NAMESPACE + '.node.memory_pressure', check.OK)
aggregator.assert_service_check(NAMESPACE + '.node.network_unavailable', check.OK)
Expand All @@ -303,7 +306,7 @@ def test_update_kube_state_metrics(aggregator, instance, check):
NAMESPACE + '.nodes.by_condition', tags=['condition:ready', 'status:false', 'optional:tag1'], value=0
)
aggregator.assert_metric(
NAMESPACE + '.nodes.by_condition', tags=['condition:ready', 'status:unknown', 'optional:tag1'], value=0
NAMESPACE + '.nodes.by_condition', tags=['condition:ready', 'status:unknown', 'optional:tag1'], value=1
)

# Make sure we send counts for all phases to avoid no-data graphing issues
Expand Down Expand Up @@ -886,9 +889,9 @@ def test_telemetry(aggregator, instance):

for _ in range(2):
check.check(instance)
aggregator.assert_metric(NAMESPACE + '.telemetry.payload.size', tags=['optional:tag1'], value=94412.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.processed.count', tags=['optional:tag1'], value=1002.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.input.count', tags=['optional:tag1'], value=1334.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.payload.size', tags=['optional:tag1'], value=94499.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.processed.count', tags=['optional:tag1'], value=1004.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.input.count', tags=['optional:tag1'], value=1336.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.blacklist.count', tags=['optional:tag1'], value=24.0)
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.ignored.count', tags=['optional:tag1'], value=332.0)
aggregator.assert_metric(
Expand Down

0 comments on commit e5ccc64

Please sign in to comment.