From 8296957af554d916cf66387e4d85a8b64d48ed17 Mon Sep 17 00:00:00 2001 From: Gleb Tcivie Date: Tue, 2 Jul 2024 22:12:08 +0300 Subject: [PATCH 1/2] Fix hop limit to be gauge instead of counter --- exporter/processor_base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exporter/processor_base.py b/exporter/processor_base.py index ec9d2ef..3fc03a3 100644 --- a/exporter/processor_base.py +++ b/exporter/processor_base.py @@ -20,7 +20,7 @@ class MessageProcessor: self.hop_start_gauge = None self.via_mqtt_counter = None self.want_ack_counter = None - self.hop_limit_counter = None + self.hop_limit_gauge = None self.rx_snr_gauge = None self.rx_time_histogram = None self.total_packets_counter = None @@ -73,7 +73,7 @@ class MessageProcessor: registry=self.registry ) # Counter for hop_limit - self.hop_limit_counter = Counter( + self.hop_limit_gauge = Gauge( 'mesh_packet_hop_limit', 'Hop limit of mesh packets', common_labels, @@ -205,9 +205,9 @@ class MessageProcessor: **common_labels ).set(mesh_packet.rx_snr) - self.hop_limit_counter.labels( + self.hop_limit_gauge.labels( **common_labels - ).inc(mesh_packet.hop_limit) + ).set(mesh_packet.hop_limit) if mesh_packet.want_ack: self.want_ack_counter.labels( From a080bea217de8473259f382c8ed9ed8479f152ca Mon Sep 17 00:00:00 2001 From: Gleb Tcivie Date: Wed, 3 Jul 2024 00:17:18 +0300 Subject: [PATCH 2/2] Fix missing data in prometheus metrics --- exporter/client_details.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/client_details.py b/exporter/client_details.py index 5078848..3e462d0 100644 --- a/exporter/client_details.py +++ b/exporter/client_details.py @@ -24,7 +24,7 @@ class ClientDetails: def get_role_name_from_role(role): descriptor = Config.DeviceConfig.Role.DESCRIPTOR for enum_value in descriptor.values: - if enum_value.number == role: + if enum_value.number == role or enum_value.name == role: return enum_value.name return 'UNKNOWN_ROLE' @@ -32,6 +32,6 @@ class ClientDetails: def get_hardware_model_name_from_code(hardware_model): descriptor = HardwareModel.DESCRIPTOR for enum_value in descriptor.values: - if enum_value.number == hardware_model: + if enum_value.number == hardware_model or enum_value.name == hardware_model: return enum_value.name return 'UNKNOWN_HARDWARE_MODEL'