feat: add start and params

This commit is contained in:
dettlaff 2024-06-21 20:33:37 +04:00
parent 165ef260b5
commit c9e73c17f9

View file

@ -33,22 +33,27 @@ class PrometheusQueries:
)
@staticmethod
def cpu_usage() -> PrometheusInfo:
def cpu_usage(
start: int = int((datetime.now() - timedelta(minutes=20)).timestamp()),
end: int = int(datetime.now().timestamp()),
step: int = 60,
) -> PrometheusInfo:
"""Get CPU information"""
start = int((datetime.now() - timedelta(minutes=20)).timestamp())
end = int(datetime.now().timestamp())
query = '100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)'
params = {"query": query, "start": start, "end": end, "step": 60}
params = {"query": query, "start": start, "end": end, "step": step}
return self._send_request(params=params)
@staticmethod
def disk_usage() -> PrometheusInfo:
def disk_usage(
start: int = int((datetime.now() - timedelta(minutes=20)).timestamp()),
end: int = int(datetime.now().timestamp()),
step: int = 60,
) -> PrometheusInfo:
"""Get disk usage information"""
start = int((datetime.now() - timedelta(minutes=20)).timestamp())
end = int(datetime.now().timestamp())
query = '100 - (100 * ((node_filesystem_avail_bytes{mountpoint="/",fstype!="rootfs"} ) / (node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"}) ))'
params = {"query": query, "start": start, "end": end, "step": 60}
params = {"query": query, "start": start, "end": end, "step": step}
return self._send_request(params=params)