diff --git a/backend/capellacollab/sessions/idletimeout.py b/backend/capellacollab/sessions/idletimeout.py index 164b0f9e1..f3a410628 100644 --- a/backend/capellacollab/sessions/idletimeout.py +++ b/backend/capellacollab/sessions/idletimeout.py @@ -29,7 +29,7 @@ def terminate_idle_session(): log.error("Could not collect idle sessions from Prometheus") return for metric in response.json()["data"]["result"]: - if session_id := metric.get("metric", {}).get("app"): + if session_id := metric.get("metric", {}).get("session_id"): log.info("Terminating idle session %s", session_id) with database.SessionLocal() as db: if session := crud.get_session_by_id(db, session_id): diff --git a/backend/capellacollab/sessions/injection.py b/backend/capellacollab/sessions/injection.py index 5ed6d45e2..06effd3f7 100644 --- a/backend/capellacollab/sessions/injection.py +++ b/backend/capellacollab/sessions/injection.py @@ -28,7 +28,7 @@ def get_last_seen(sid: str) -> str: response.raise_for_status() for session in response.json()["data"]["result"]: - if sid == session["metric"]["app"]: + if sid == session["metric"]["session_id"]: return _get_last_seen(float(session["value"][1])) log.error("No session was found.") diff --git a/backend/tests/sessions/test_session_idletimeout.py b/backend/tests/sessions/test_session_idletimeout.py index 611cd9465..bc5c55420 100644 --- a/backend/tests/sessions/test_session_idletimeout.py +++ b/backend/tests/sessions/test_session_idletimeout.py @@ -53,7 +53,9 @@ def test_idle_sessions(monkeypatch): monkeypatch.setattr( requests, "get", - lambda *args, **kwargs: MockResponse({"metric": {"app": session_id}}), + lambda *args, **kwargs: MockResponse( + {"metric": {"session_id": session_id}} + ), ) monkeypatch.setattr( capellacollab.sessions.operators,