From 83071514a3fd6de655f09494986f5f9eddaf6bf1 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 14 Feb 2026 13:40:42 +0300 Subject: [PATCH] fc-server: add metrics visualization dashboard Adds a /metrics page with Chart.js charts, which requires an annoying CDN fetch but until I figure out a good method of fetching things during build it's our best bet. I've pinned the thing so it's probably good. The page displays build counts, duration percentiles and system distribution. Time range and project filters are included, and the metrics page is linked from navigation. Signed-off-by: NotAShelf Change-Id: I99059594c29a9b35d2fd4d140628d6f46a6a6964 --- crates/server/src/routes/dashboard.rs | 20 ++ crates/server/templates/base.html | 1 + crates/server/templates/metrics.html | 407 ++++++++++++++++++++++++++ 3 files changed, 428 insertions(+) create mode 100644 crates/server/templates/metrics.html diff --git a/crates/server/src/routes/dashboard.rs b/crates/server/src/routes/dashboard.rs index 7a4408a..bbbbf3b 100644 --- a/crates/server/src/routes/dashboard.rs +++ b/crates/server/src/routes/dashboard.rs @@ -423,6 +423,13 @@ struct StarredTemplate { auth_name: String, } +#[derive(Template)] +#[template(path = "metrics.html")] +struct MetricsTemplate { + is_admin: bool, + auth_name: String, +} + // --- Handlers --- async fn home( @@ -1565,6 +1572,18 @@ async fn starred_page( ) } +async fn metrics_page(extensions: Extensions) -> Html { + let tmpl = MetricsTemplate { + is_admin: is_admin(&extensions), + auth_name: auth_name(&extensions), + }; + Html( + tmpl + .render() + .unwrap_or_else(|e| format!("Template error: {e}")), + ) +} + pub fn router() -> Router { Router::new() .route("/login", get(login_page).post(login_action)) @@ -1583,4 +1602,5 @@ pub fn router() -> Router { .route("/admin", get(admin_page)) .route("/users", get(users_page)) .route("/starred", get(starred_page)) + .route("/metrics", get(metrics_page)) } diff --git a/crates/server/templates/base.html b/crates/server/templates/base.html index f120e85..59f8c22 100644 --- a/crates/server/templates/base.html +++ b/crates/server/templates/base.html @@ -16,6 +16,7 @@ Queue Channels Starred + Metrics Users Admin diff --git a/crates/server/templates/metrics.html b/crates/server/templates/metrics.html new file mode 100644 index 0000000..0caf835 --- /dev/null +++ b/crates/server/templates/metrics.html @@ -0,0 +1,407 @@ +{% extends "base.html" %} + +{% block title %}Metrics - FC CI{% endblock %} + +{% block auth %} +{% if !auth_name.is_empty() %} +{{ auth_name }} +
+{% else %} +Login +{% endif %} +{% endblock %} + +{% block content %} +

Build Metrics Dashboard

+ +{% if is_admin %} +

Showing system-wide metrics. Filter by project below to view specific metrics.

+{% endif %} + +
+ + + + + +
+ +
+
+

Build Counts Over Time

+ +
+ +
+

Build Duration Percentiles

+ +
+ +
+

Builds by System

+ +
+ +
+

Success Rate Trend

+ +
+
+{% endblock %} + +{% block scripts %} + + + + +{% endblock %}