Cloud

Operational Dashboard

Self-contained, auto-refreshing monitoring page that reads your Prometheus metrics and health endpoints, served with strict security headers.

2 min readUpdated DocumentationEdit this page
On this page5

Overview

createDashboard() returns a route handler that serves a responsive, self-contained HTML page. In the browser it fetches your existing health and metrics endpoints and refreshes on an interval. The endpoints themselves come from elsewhere, for example HealthChecker and metricsHandler in @axiljs/observability.

Usage

TypeScript
TS
1import { createDashboard } from '@axiljs/cloud'
2
3app.get('/dashboard', createDashboard({
4  title: 'My Cloud Console',
5  metricsEndpoint: '/metrics',
6  healthEndpoint: '/health',
7  refreshMs: 5000,
8}))

Options

OptionTypeDefaultDescription
titlestring'AxilJS Cloud Dashboard'Page title
metricsEndpointstring'/metrics'Path fetched for Prometheus metrics
healthEndpointstring'/health'Path fetched for health JSON
refreshMsnumber5000Auto-refresh interval; values below 1000 are raised to 1000

Security

The handler sets these response headers:

  • Content-Security-Policy: default-src 'self', inline styles and scripts only, connect-src 'self'
  • X-Frame-Options: DENY
  • X-Content-Type-Options: nosniff
  • Referrer-Policy: strict-origin-when-cross-origin
  • Permissions-Policy: camera=(), microphone=(), geolocation=()
  • Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate

title and the endpoint paths are HTML-escaped. Because of connect-src 'self', the metrics and health endpoints must be on the same origin as the dashboard.

Production Deployment

Mount the dashboard behind authentication in production:

TypeScript
TS
1import { JWT, authenticate, requireRole } from '@axiljs/auth'
2
3const jwt = new JWT(process.env.JWT_SECRET!)
4
5app.get(
6  '/dashboard',
7  authenticate(jwt),
8  requireRole('admin'),
9  createDashboard({ title: 'Admin Dashboard' })
10)

Note

Global middleware added with app.use() runs for every route, so if multiTenancy() is registered globally the dashboard also requires a tenant. Apply multiTenancy() as route middleware or on a mounted Router instead, or pass required: false.

Was this page helpful?

Help improve the documentation

AxilJS is open source and documentation improvements are welcome.

AxilJS DocumentationMIT License · Built by SyntaxilitY