From 959597be5fe70ab7930a8d705659a621e1d612ba Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 29 Jul 2024 19:12:34 +0300 Subject: [PATCH] fix: Do not include unused devices in disk metrics --- selfprivacy_api/utils/monitoring.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/selfprivacy_api/utils/monitoring.py b/selfprivacy_api/utils/monitoring.py index 6923b28..95712eb 100644 --- a/selfprivacy_api/utils/monitoring.py +++ b/selfprivacy_api/utils/monitoring.py @@ -131,7 +131,11 @@ class MonitoringQueries: id=MonitoringQueries._clean_slice_id( x["metric"][id_key], clean_id=clean_id ), - values=[MonitoringQueries._prometheus_value_to_monitoring_value(x["value"])], + values=[ + MonitoringQueries._prometheus_value_to_monitoring_value( + x["value"] + ) + ], ), response["result"], ) @@ -357,7 +361,7 @@ class MonitoringQueries: start_timestamp = int(start.timestamp()) end_timestamp = int(end.timestamp()) - query = """100 - (100 * sum by (device) (node_filesystem_avail_bytes{fstype!="rootfs"}) / sum by (device) (node_filesystem_size_bytes{fstype!="rootfs"}))""" + query = """100 - (100 * sum by (device) (node_filesystem_avail_bytes{fstype!="rootfs",fstype!="ramfs",fstype!="tmpfs",mountpoint!="/efi"}) / sum by (device) (node_filesystem_size_bytes{fstype!="rootfs",fstype!="ramfs",fstype!="tmpfs",mountpoint!="/efi"}))""" data = MonitoringQueries._send_range_query( query, start_timestamp, end_timestamp, step, result_type="matrix"