Skip to content
Snippets Groups Projects

Update

Merged Gregor Cerar requested to merge dev into main
10 files
+ 121
63
Compare changes
  • Side-by-side
  • Inline
Files
10
+ 8
8
@@ -12,12 +12,12 @@ import kubernetes as k8s
from fastapi import FastAPI, HTTPException
from kubernetes.client import V1Pod, V1PodList
from src.settings import PromConfig, get_config
from src.settings import PromConfig
from src.structures import PodStats, PodStatus, TrafficStats
# create logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)
# create formatter
# formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
@@ -155,7 +155,7 @@ async def _get_pod_outbound_traffic_latency(
queries.append(template.format(phi=phi, pod=pod_name, timestamp=timestamp, label=label))
query = "\n or \n".join(queries)
logger.debug(f"query={' '.join(query.split())}")
logger.debug(f"{query=}")
try:
async with httpx.AsyncClient() as client:
@@ -236,7 +236,7 @@ async def get_workloads_list():
@app.get("/api/v1/pods/{namespace}/{pod_name}")
async def get_workload(namespace: str, pod_name: str):
config = get_config()
prom_config = PromConfig()
timestamp = datetime.now().timestamp()
try:
@@ -265,10 +265,10 @@ async def get_workload(namespace: str, pod_name: str):
# Process async requests to Prometheus server
req_rate, res_rate, res_rate_by_code, res_time_quantiles_ms = await asyncio.gather(
_get_pod_inbound_traffic_rate(pod_name, timestamp, config.prometheus),
_get_pod_outbound_traffic_rate(pod_name, timestamp, config.prometheus),
_get_outbound_traffic_rate_by_status_code(pod_name, timestamp, config.prometheus),
_get_pod_outbound_traffic_latency(pod_name, timestamp, config.prometheus),
_get_pod_inbound_traffic_rate(pod_name, timestamp, prom_config),
_get_pod_outbound_traffic_rate(pod_name, timestamp, prom_config),
_get_outbound_traffic_rate_by_status_code(pod_name, timestamp, prom_config),
_get_pod_outbound_traffic_latency(pod_name, timestamp, prom_config),
)
traffic_stats = TrafficStats(
Loading