Observability
This guide demonstrates the built-in observability endpoints provided by Teleportal for monitoring and health checks.
What it demonstrates
Section titled “What it demonstrates”- Accessing the
/healthendpoint for server health checks - Accessing the
/metricsendpoint for Prometheus-compatible metrics - Accessing the
/statusendpoint for server status information
Server Setup
Section titled “Server Setup”import { Server } from "teleportal/server";import { getMetricsHandler, getHealthHandler, getStatusHandler } from "teleportal/monitoring";
const server = new Server({ getStorage: async (ctx) => { // Your storage implementation return documentStorage; },});
// Expose observability endpointsapp.get("/metrics", getMetricsHandler(server));app.get("/health", getHealthHandler(server));app.get("/status", getStatusHandler(server));Metrics Endpoint
Section titled “Metrics Endpoint”The /metrics endpoint returns Prometheus-formatted metrics:
curl http://localhost:3000/metricsMetrics include:
teleportal_sessions_active: Current number of active sessionsteleportal_clients_active: Current number of active clientsteleportal_documents_opened_total: Total documents openedteleportal_messages_processed_total: Total messages processedteleportal_message_duration_seconds: Message processing duration
Health Endpoint
Section titled “Health Endpoint”The /health endpoint returns server health status:
curl http://localhost:3000/healthResponse:
{ "status": "healthy", "timestamp": "2024-01-01T00:00:00.000Z", "checks": { ... }, "uptime": 3600}Status Endpoint
Section titled “Status Endpoint”The /status endpoint returns detailed operational status:
curl http://localhost:3000/statusResponse:
{ "nodeId": "node-123", "activeClients": 10, "activeSessions": 5, "totalMessagesProcessed": 1000, "totalDocumentsOpened": 50, "messageTypeBreakdown": { "doc": 500, "awareness": 300, "file": 200 }, "uptime": 3600}Next Steps
Section titled “Next Steps”- Monitoring - Learn more about monitoring
- Server - Server configuration