From ab4920dd3a3b2c4f7a9d40099ca26ea97dec522c Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 29 Jul 2024 18:53:45 +0300 Subject: [PATCH] fix: zero offsets --- selfprivacy_api/utils/monitoring.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/selfprivacy_api/utils/monitoring.py b/selfprivacy_api/utils/monitoring.py index 630e843..12aa510 100644 --- a/selfprivacy_api/utils/monitoring.py +++ b/selfprivacy_api/utils/monitoring.py @@ -263,7 +263,10 @@ class MonitoringQueries: offset, duration = MonitoringQueries._calculate_offset_and_duration(start, end) - query = f'max_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s] offset {offset}s)' + if offset == 0: + query = f'max_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s])' + else: + query = f'max_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s] offset {offset}s)' data = MonitoringQueries._send_query(query, result_type="vector") @@ -299,7 +302,10 @@ class MonitoringQueries: offset, duration = MonitoringQueries._calculate_offset_and_duration(start, end) - query = f'avg_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s] offset {offset}s)' + if offset == 0: + query = f'avg_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s])' + else: + query = f'avg_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s] offset {offset}s)' data = MonitoringQueries._send_query(query, result_type="vector")