Skip to content

feat(dashboard): add instance health dashboard on GET / endpoint#286

Merged
polaz merged 7 commits intomainfrom
feat/#275-feat-instance-health-dashboard-on-get--endpoint
Feb 4, 2026
Merged

feat(dashboard): add instance health dashboard on GET / endpoint#286
polaz merged 7 commits intomainfrom
feat/#275-feat-instance-health-dashboard-on-get--endpoint

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Feb 4, 2026

Summary

  • Add health dashboard endpoint at GET / for server monitoring
  • Dashboard shows registered GitLab instances, health status, rate limit metrics
  • Supports content negotiation: HTML for browsers, JSON for API clients
  • Safe for MCP clients (they use POST /mcp, not GET /)

Changes

New files

  • src/dashboard/metrics.ts — MetricsCollector aggregating data from InstanceRegistry, SessionManager
  • src/dashboard/html-template.ts — Responsive HTML template with dark theme
  • src/dashboard/handler.ts — Express handler with Accept header content negotiation
  • src/dashboard/index.ts — Barrel exports

Modified files

  • src/config.ts — Added DASHBOARD_ENABLED env var (default: true)
  • src/server.ts — Registered GET / route before MCP middleware

Features

  • Instance health status: healthy/degraded/offline based on latency, queue, rejection rate
  • Rate limit metrics per instance (active/queued/total requests)
  • Session count (anonymized)
  • Server configuration summary
  • Auto-refresh every 30 seconds
  • XSS protection via HTML escaping
  • Disable with DASHBOARD_ENABLED=false

Test plan

  • 44 unit tests added for metrics, handler, and HTML template
  • All 4548 tests pass
  • Lint passes
  • Build succeeds

Closes #275

- Add dashboard module with metrics collector, HTML template, and handler
- Dashboard shows server info, registered instances, health status, sessions
- Supports content negotiation: HTML for browsers, JSON for API clients
- Add DASHBOARD_ENABLED config (default true, disable with =false)
- Instances show health status (healthy/degraded/offline) based on metrics
- HTML includes auto-refresh every 30 seconds
- Safe for MCP clients - they use POST /mcp, not GET /
- Add 44 unit tests for metrics, handler, and HTML template

Closes #275
Copilot AI review requested due to automatic review settings February 4, 2026 23:16
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 4, 2026

Test Coverage Report

Overall Coverage: 95.77%

Metric Percentage
Statements 95.24%
Branches 86.12%
Functions 94.42%
Lines 95.77%

View detailed coverage report

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 93.46405% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/dashboard/html-template.ts 90.16% 0 Missing and 6 partials ⚠️
src/server.ts 25.00% 2 Missing and 1 partial ⚠️
src/dashboard/metrics.ts 98.36% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements an instance health dashboard accessible at GET / that provides real-time visibility into the GitLab MCP server's multi-instance federation state, health metrics, and configuration. The dashboard supports content negotiation, serving HTML for browsers and JSON for API clients, while remaining safe for MCP clients that use POST endpoints.

Changes:

  • Adds a comprehensive health monitoring dashboard with server metrics, instance health status, rate limiting metrics, and session counts
  • Implements content negotiation to serve HTML dashboards to browsers and JSON to API clients
  • Provides 44 unit tests ensuring metrics collection, HTML rendering, and HTTP handling work correctly

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/server.ts Registers GET / route for dashboard when DASHBOARD_ENABLED is true (default)
src/config.ts Adds DASHBOARD_ENABLED environment variable configuration
src/dashboard/metrics.ts Implements metrics collection from InstanceRegistry and SessionManager with health status determination
src/dashboard/handler.ts Handles HTTP requests with Accept header content negotiation between HTML and JSON
src/dashboard/html-template.ts Generates responsive HTML with dark theme, XSS escaping, and auto-refresh
src/dashboard/index.ts Barrel exports for dashboard module
tests/unit/dashboard/metrics.test.ts Tests metrics collection, status determination, and uptime formatting
tests/unit/dashboard/html-template.test.ts Tests HTML rendering, XSS protection, and content formatting
tests/unit/dashboard/handler.test.ts Tests content negotiation and response generation

polaz added 4 commits February 5, 2026 01:20
- Vite/Rollup cannot resolve .d.ts files as runtime imports
- Renamed declaration file to regular .ts (content unchanged)
- File contains `declare global` + `export {}` which is valid in both formats

Fixes #285
- Add try/catch in dashboardHandler for collectMetrics/renderDashboard failures
- Add safe URL parsing in renderInstanceCard with fallback to raw URL
- Use GITLAB_TOKEN config constant instead of direct process.env access
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

- Remove unused lastSuccessfulRequestMs parameter from determineInstanceStatus
- Add .js extension to dashboard import in server.ts
- Add safe URL parsing for session hostnames in html-template.ts
- Add comprehensive tests for collectMetrics function
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

- Add tests for error handling in dashboardHandler
- Add tests for getMetrics export function
- Add tests for OAuth and token auth modes
- Add tests for unknown status indicator
- Add tests for invalid URL parsing fallbacks
- Add tests for queue filling warning
- Add tests for formatRelativeTime (hours, days)
- Add tests for invalid URL in sessions byInstance

Coverage: Lines 100%, Branches 92.85%
@polaz polaz changed the title feat(dashboard): Instance Health Dashboard on GET / endpoint feat(dashboard): add instance health dashboard on GET / endpoint Feb 4, 2026
@polaz polaz requested a review from Copilot February 4, 2026 23:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@polaz polaz merged commit de47c40 into main Feb 4, 2026
28 checks passed
@polaz polaz deleted the feat/#275-feat-instance-health-dashboard-on-get--endpoint branch February 4, 2026 23:50
sw-release-bot bot pushed a commit that referenced this pull request Feb 4, 2026
## [6.56.0](v6.55.1...v6.56.0) (2026-02-04)

### Features

* **dashboard:** add instance health dashboard on GET / endpoint ([#286](#286)) ([de47c40](de47c40)), closes [#275](#275) [#287](#287) [#285](#285)
@sw-release-bot
Copy link
Copy Markdown

sw-release-bot bot commented Feb 4, 2026

🎉 This PR is included in version 6.56.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Instance Health Dashboard on GET / endpoint

2 participants