fix: zero offsets

This commit is contained in:
Inex Code 2024-07-29 18:53:45 +03:00
parent 60ce3b773d
commit ab4920dd3a

View file

@ -263,6 +263,9 @@ class MonitoringQueries:
offset, duration = MonitoringQueries._calculate_offset_and_duration(start, end) 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])'
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"}}[{duration}s] offset {offset}s)'
data = MonitoringQueries._send_query(query, result_type="vector") data = MonitoringQueries._send_query(query, result_type="vector")
@ -299,6 +302,9 @@ class MonitoringQueries:
offset, duration = MonitoringQueries._calculate_offset_and_duration(start, end) 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])'
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"}}[{duration}s] offset {offset}s)'
data = MonitoringQueries._send_query(query, result_type="vector") data = MonitoringQueries._send_query(query, result_type="vector")