Skip to main content
Stream real-time metrics from your sandbox using Server-Sent Events (SSE). This provides continuous monitoring of agent performance metrics without polling.

Overview

SSE monitoring is ideal for:
  • Real-time dashboards and visualizations
  • Continuous agent performance monitoring
  • Alerting on threshold breaches
  • Long-term performance tracking
SSE monitoring is available through the Control Plane API endpoint /v1/sandboxes/:id/metrics/stream. This streams metrics from the VM agent to your application.

Basic Streaming

Connect to the metrics stream and receive real-time updates:

Processing Stream Events

Handle different event types from the SSE stream:

Building a Metrics Dashboard

Create a simple dashboard that displays real-time metrics:

Alerting on Thresholds

Set up alerts when metrics exceed thresholds:

Best Practices

Use SSE for real-time monitoring when you need continuous updates. For one-time snapshots, use get_metrics_snapshot() instead.
Handle reconnection logic in production applications. SSE connections can drop, and you should reconnect automatically.
SSE streams consume resources. Close connections when no longer needed to free up server resources.
Throttle processing if you’re receiving metrics faster than you can process them. The stream sends updates frequently.

API Reference

Control Plane API

  • GET /v1/sandboxes/:id/metrics/stream - Stream metrics via SSE
    • Headers: Authorization: Bearer {token}, Accept: text/event-stream
    • Response: Server-Sent Events stream with JSON metrics data

SSE Event Format

Next Steps