Overhaul Server Metrics

What does this MR do and why?

Overhauls the server metrics page to provide more useful time ranges, better chart performance, and additional metrics.

Time range selection:

  • Replaced the old "1/2/3 Days" dropdown with a full date range picker (vanilla-datetimerange-picker) supporting both preset ranges (1h, 3h, 6h, 12h, 24h, 2d, 7d) and custom absolute date/time selection
  • Includes mobile-friendly full-screen overlay and keyboard input support (Enter to apply)
  • Server timezone is displayed and handled consistently throughout
  • Live WebSocket updates pause automatically when viewing a historical custom range, and resume on preset ranges

New metrics and chart improvements:

  • Added RAM GB as a new metric alongside RAM % for absolute memory visibility
  • Added dual Y-axes: left for percentages (CPU %, RAM %), right for absolute values (Players, RAM GB)
  • Enabled player count tracking for Hytale servers (previously only worked for Minecraft Java)
  • Chart.js v3+ API compatibility fixes for tooltips and global defaults

Performance:

  • Added LTTB (Largest Triangle Three Buckets) chart decimation, dynamically scaled to screen width (~1 point per 3 CSS pixels)
  • Backend adaptive sampling reduces data points based on time span (full resolution at 6h, progressively sampled up to 7d+)
  • Offline/gap periods render as line breaks instead of misleading connected lines

Backend:

  • New StatsConverter and MetricsTimeRangeHelper helper classes
  • New get_history_stats_adaptive() and get_history_stats_by_date_range() query methods
  • Raw memory bytes (mem_raw) tracked through the full stats pipeline for accurate GB calculations

Issues Closed:

Screenshots or screen recordings

Screenshot_2026-02-15_182808

Screenshot_2026-02-15_172238

Screenshot_2026-02-15_182825 Screenshot_2026-02-15_174108 Screenshot_2026-02-15_174118

How to set up and validate locally

  1. Start a Crafty 4 instance with at least one server that has historical metrics data
  2. Navigate to the server's Metrics page
  3. Verify the date range picker shows preset ranges (1h–7d) and allows custom date selection
  4. Select a historical range and confirm the chart renders without live updates appending
  5. Switch back to a relative range and confirm live WebSocket updates resume
  6. Check that RAM GB, CPU %, RAM %, and Player count all display on the chart with dual Y-axes
  7. On mobile or narrow viewport, verify the date picker opens as a full-screen overlay

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • Have you checked this doesn't interfere/conflict/duplicate someone elses work?
  • Have you fully tested your changes?
  • Have you resolved any lint issues?
  • Have you assigned a reviewer?
  • Have you applied correct labels?
Edited by Corey Koval

Merge request reports

Loading