#4646·srs

Proxy: Add the API to obtain the deployment information of origins and streams from the proxy

Author: liukun4515Created Mar 16, 2026Updated Aug 30, 2026
LabelsTransByAIEnglishNative

What is the business background? Please provide a description.

As a DevOps engineer managing SRS Proxy clusters, I need to monitor the cluster state and debug routing issues. Currently, there is no API to query which origins are registered or which streams are routed to which origin.


Is your feature request related to a problem? Please describe.

Yes. When operating SRS Proxy with multiple origin servers, I cannot:

  1. See which origins are registered - I don't know if an origin successfully registered after restart
  2. Track stream routing - I don't know which origin is handling a specific stream
  3. Debug connection failures - When a stream fails, I can't tell if it's because the stream is mapped to a dead origin

The only way to get this information is reading logs, which is not suitable for monitoring or automation.


Describe the solution you'd like

Add two basic HTTP API endpoints to System API (port 12025):

1. GET /api/v1/origins

List all registered origin servers with their health status.

Example response:

json
{
  "code": 0,
  "data": {
    "total": 3,
    "alive": 2,
    "origins": [
      {
        "id": "server-001-service-123-pid-456",
        "ip": "192.168.1.10",
        "alive": true,
        "last_heartbeat_seconds": 10
      },
      {
        "id": "server-002-service-789-pid-789",
        "ip": "192.168.1.11",
        "alive": false,
        "last_heartbeat_seconds": 350
      }
    ]
  }
}

2. GET /api/v1/streams

List all stream-to-origin mappings.

Example response:
{
  "code": 0,
  "data": {
    "total": 3,
    "streams": [
      {
        "stream_url": "live/stream",
        "origin_id": "server-001-service-123-pid-456",
        "origin_ip": "192.168.1.10",
        "origin_alive": true
      },
      {
        "stream_url": "live/stream2",
        "origin_id": "server-002-service-789-pid-789",
        "origin_ip": "192.168.1.11",
        "origin_alive": false
      }
    ]
  }
}

Use cases:
- Monitor cluster health
- Debug stream routing issues
- Build monitoring dashboards
- Detect stale mappings (streams mapped to dead origins)

---
Describe alternatives you've considered

- Reading logs: Not real-time, hard to parse
- Querying Redis directly (for Redis LB): Only works for Redis mode, not a proper API
- Using pprof: Only for debugging, not business metrics

---
Additional context

The data already exists in memory (servers and picked maps in proxy/internal/lb/mem.go), we just need an HTTP API to expose it.

Currently, System API only provides:
- GET /api/v1/versions - version info
- POST /api/v1/srs/register - origin registration (write-only)

There is no API to read the cluster state.

---