Operational Dashboard
Self-contained, auto-refreshing monitoring page that reads your Prometheus metrics and health endpoints, served with strict security headers.
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
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
| Option | Type | Default | Description |
|---|---|---|---|
title | string | 'AxilJS Cloud Dashboard' | Page title |
metricsEndpoint | string | '/metrics' | Path fetched for Prometheus metrics |
healthEndpoint | string | '/health' | Path fetched for health JSON |
refreshMs | number | 5000 | Auto-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: DENYX-Content-Type-Options: nosniffReferrer-Policy: strict-origin-when-cross-originPermissions-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:
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?