Skip to content

Observability

This guide demonstrates the built-in observability endpoints provided by Teleportal for monitoring and health checks.

  • Accessing the /health endpoint for server health checks
  • Accessing the /metrics endpoint for Prometheus-compatible metrics
  • Accessing the /status endpoint for server status information
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 endpoints
app.get("/metrics", getMetricsHandler(server));
app.get("/health", getHealthHandler(server));
app.get("/status", getStatusHandler(server));

The /metrics endpoint returns Prometheus-formatted metrics:

Terminal window
curl http://localhost:3000/metrics

Metrics include:

  • teleportal_sessions_active: Current number of active sessions
  • teleportal_clients_active: Current number of active clients
  • teleportal_documents_opened_total: Total documents opened
  • teleportal_messages_processed_total: Total messages processed
  • teleportal_message_duration_seconds: Message processing duration

The /health endpoint returns server health status:

Terminal window
curl http://localhost:3000/health

Response:

{
"status": "healthy",
"timestamp": "2024-01-01T00:00:00.000Z",
"checks": { ... },
"uptime": 3600
}

The /status endpoint returns detailed operational status:

Terminal window
curl http://localhost:3000/status

Response:

{
"nodeId": "node-123",
"activeClients": 10,
"activeSessions": 5,
"totalMessagesProcessed": 1000,
"totalDocumentsOpened": 50,
"messageTypeBreakdown": {
"doc": 500,
"awareness": 300,
"file": 200
},
"uptime": 3600
}