Active workspace metrics via prometheus

We are unfortunately not using k8s for our current coder deployment, and I already looked at the observability repo here: https://github.com/coder/observability/tree/main?tab=readme-ov-file and found that many of the dashboards there are strongly tied to k8s metrics on top of the prometheus metrics from coder. I would like to display on a dashboard the current active workspaces, however, this does not seem possible with the current prometheus metrics, maybe I'm wrong.. Has anyone figured out a way to reliably display the current "running" workspace count, purely with the coder prometheus metrics?
GitHub
GitHub - coder/observability
Contribute to coder/observability development by creating an account on GitHub.
6 Replies
Codercord
Codercord4w ago
<#1288834316448825344>
Category
Other
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
zounce
zounce4w ago
coderd_workspace_latest_build_status{status="failed",template_name="docker",template_version="intelligent_williamson3",workspace_owner="admin",workspace_transition="stop"} 1
coderd_workspace_latest_build_status{status="failed",template_name="docker",template_version="sweet_gould9",workspace_owner="admin",workspace_transition="stop"} 1
coderd_workspace_latest_build_status{status="succeeded",template_name="docker",template_version="sweet_gould9",workspace_owner="admin",workspace_transition="stop"} 1
coderd_workspace_latest_build_status{status="succeeded",template_name="scratch",template_version="clever_khayyam6",workspace_owner="admin",workspace_transition="start"} 1
coderd_workspace_latest_build_status{status="failed",template_name="docker",template_version="intelligent_williamson3",workspace_owner="admin",workspace_transition="stop"} 1
coderd_workspace_latest_build_status{status="failed",template_name="docker",template_version="sweet_gould9",workspace_owner="admin",workspace_transition="stop"} 1
coderd_workspace_latest_build_status{status="succeeded",template_name="docker",template_version="sweet_gould9",workspace_owner="admin",workspace_transition="stop"} 1
coderd_workspace_latest_build_status{status="succeeded",template_name="scratch",template_version="clever_khayyam6",workspace_owner="admin",workspace_transition="start"} 1
Filtering this metric to labels where status is succeeded and workspace_transition is start should get you what you're looking for? looks consistent with what /deployment/stats returns This metric was undocumented, just pr'd to fix that, so thank you!
jozef
jozef4w ago
Fantastic, I'll give it a quick test drive Seems to work nicely, I also managed to get a nice view of workspaces over time period per user with the following
count by (username, workspace_name) (coderd_agents_connections{status="connected"})
count by (username, workspace_name) (coderd_agents_connections{status="connected"})
zounce
zounce4w ago
Awesome!
Phorcys
Phorcys4w ago
great!
Codercord
Codercord4w ago
@Phorcys closed the thread.
Want results from more Discord servers?
Add your server