From 806c3052ff08d85f737191946a43a79aa0f626cb Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 30 Jul 2024 15:22:23 +0300 Subject: [PATCH] fix: Take swap into account when counting service RAM usage metrics --- selfprivacy_api/utils/monitoring.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfprivacy_api/utils/monitoring.py b/selfprivacy_api/utils/monitoring.py index 036339f..8d8e8f5 100644 --- a/selfprivacy_api/utils/monitoring.py +++ b/selfprivacy_api/utils/monitoring.py @@ -281,9 +281,9 @@ class MonitoringQueries: offset, duration = MonitoringQueries._calculate_offset_and_duration(start, end) if offset == 0: - query = f'max_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s])' + query = f'max_over_time((container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}+container_memory_swap{{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)' + query = f'max_over_time((container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}+container_memory_swap{{id!~".*slice.*slice", id=~".*slice"}})[{duration}s:] offset {offset}s)' data = MonitoringQueries._send_query(query, result_type="vector") @@ -320,9 +320,9 @@ class MonitoringQueries: offset, duration = MonitoringQueries._calculate_offset_and_duration(start, end) if offset == 0: - query = f'avg_over_time(container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}[{duration}s])' + query = f'avg_over_time((container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}+container_memory_swap{{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)' + query = f'avg_over_time((container_memory_rss{{id!~".*slice.*slice", id=~".*slice"}}+container_memory_swap{{id!~".*slice.*slice", id=~".*slice"}})[{duration}s:] offset {offset}s)' data = MonitoringQueries._send_query(query, result_type="vector")