From db5f4a279b848d1c76fb38db0a9b476b58454e59 Mon Sep 17 00:00:00 2001 From: Rhys Bailey Date: Mon, 11 Mar 2024 22:50:34 +1100 Subject: [PATCH] improve labels for some process names and types --- prometheus_frigate_exporter.py | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/prometheus_frigate_exporter.py b/prometheus_frigate_exporter.py index 94c6748..99dd412 100644 --- a/prometheus_frigate_exporter.py +++ b/prometheus_frigate_exporter.py @@ -138,6 +138,46 @@ def collect(self): yield detector_inference_speed yield detector_detection_start + + # detector process stats + try: + for detector_name, detector_stats in stats['detectors'].items(): + p_pid = str(detector_stats['pid']) + label = [p_pid] # pid label + try: + # new frigate:0.13.0-beta3 stat 'cmdline' + label.append(detector_name) # name label + label.append(detector_name) # process label + label.append('detectors') # type label + label.append(self.process_stats[p_pid]['cmdline']) # cmdline label + add_metric(cpu_usages, label, self.process_stats[p_pid], 'cpu') + add_metric(mem_usages, label, self.process_stats[p_pid], 'mem') + del self.process_stats[p_pid] + except KeyError: + pass + + except KeyError: + pass + + # other named process stats + try: + for process_name, process_stats in stats['processes'].items(): + p_pid = str(process_stats['pid']) + label = [p_pid] # pid label + try: + # new frigate:0.13.0-beta3 stat 'cmdline' + label.append(process_name) # name label + label.append(process_name) # process label + label.append(process_name) # type label + label.append(self.process_stats[p_pid]['cmdline']) # cmdline label + add_metric(cpu_usages, label, self.process_stats[p_pid], 'cpu') + add_metric(mem_usages, label, self.process_stats[p_pid], 'mem') + del self.process_stats[p_pid] + except KeyError: + pass + + except KeyError: + pass # remaining process stats try: