Skip to content

Commit

Permalink
Add datacenters to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ferchault committed Jul 19, 2023
1 parent 3038116 commit a7e254a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/dashboard/app/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
col1, col2 = st.columns(2)


result = requests.get("http://hmq/usage/inspect")
result = requests.get("http://hmq/queue/inspect")

rows = []
for minutes_ago, data in result.json().items():
Expand All @@ -24,9 +24,15 @@
col2.caption("Queue depth")
col2.line_chart(df, x="age", y=["tasks_queued"])
col2.line_chart(df, x="age", y=["tasks_running"])

col1, col2 = st.columns(2)
col1.caption("Datacenters")
result = requests.get("http://hmq/datacenters/inspect")
rows = []
for datacenter, last_seen in result.json().items():
rows.append({"datacenter": datacenter, "minutes ago": last_seen})
df = pd.DataFrame(rows)
col1.dataframe(df)
# col2.caption("Tags")
# for tag in "foo bar sdjfhwsökgdjhsökgj".split():
# col2.progress(0.54, tag)#

# col1, col2 = st.columns(2)
# col1.caption("Hello")
9 changes: 9 additions & 0 deletions src/server/app/routers/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ def inspect_usage():
return ret


@app.get("/datacenters/inspect", tags=["statistics"])
def inspect_usage():
now = time.time()
ret = {}
for dc in auth.db.heartbeat.find():
ret[dc["datacenter"]] = max(0, int(now - dc["ts"]))
return ret


class QueueHasWork(BaseModel):
challenge: str = Field(..., description="Encrypted challenge from /auth/challenge")
datacenter: str = Field(..., description="Datacenter checking in.")
Expand Down

0 comments on commit a7e254a

Please sign in to comment.