Monitoring
The Monitoring API provides real-time and historical metrics, health checks, logs, and alerts for apps running on the Dooor OS runtime. Data is sourced from Prometheus (metrics) and Loki (logs).
App Metrics
/workspaces/{wsId}/monitoring/apps/{appId}/metricsReturns timeseries metric data for a specific app over a configurable time period. Each metric includes labels, values, unit, current value, average, and maximum.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| period | string | optional | Time window: 1h | 6h | 24h | 7d | 30d. Default: 24h. |
Response
{
"appId": "app_01hx...",
"serviceName": "my-api",
"period": "24h",
"cpu": {
"labels": ["2025-01-20T00:00:00Z", "2025-01-20T01:00:00Z"],
"values": [12.4, 18.7],
"unit": "%",
"current": 18.7,
"avg": 14.2,
"max": 42.1
},
"memory": {
"labels": ["2025-01-20T00:00:00Z", "2025-01-20T01:00:00Z"],
"values": [256, 312],
"unit": "MiB",
"current": 312,
"avg": 280,
"max": 380
},
"requestCount": {
"labels": ["2025-01-20T00:00:00Z", "2025-01-20T01:00:00Z"],
"values": [120, 245],
"unit": "req",
"current": 245,
"avg": 180,
"max": 512
},
"requestLatency": {
"labels": ["2025-01-20T00:00:00Z", "2025-01-20T01:00:00Z"],
"values": [42, 55],
"unit": "ms",
"current": 55,
"avg": 48,
"max": 210
},
"errorRate": {
"labels": ["2025-01-20T00:00:00Z", "2025-01-20T01:00:00Z"],
"values": [0.01, 0.02],
"unit": "%",
"current": 0.02,
"avg": 0.015,
"max": 0.05
},
"instanceCount": {
"labels": ["2025-01-20T00:00:00Z", "2025-01-20T01:00:00Z"],
"values": [2, 3],
"unit": "instances",
"current": 3,
"avg": 2,
"max": 4
}
}curl -X GET "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/apps/{appId}/metrics?period=24h" \
-H "Authorization: Bearer dor_sk_your_key_here"App Health
/workspaces/{wsId}/monitoring/apps/{appId}/healthReturns the current health status of an app. The status reflects the aggregate health of all running instances and is updated every 30 seconds.
Response
{
"appId": "app_01hx...",
"status": "healthy",
"uptime": 864000,
"lastDeployedAt": "2025-01-15T10:00:00Z",
"instanceCount": 3,
"errorRate": 0.01,
"avgLatencyMs": 48,
"lastCheckedAt": "2025-01-20T14:30:00Z"
}The status field can be one of:
| Name | Type | Required | Description |
|---|---|---|---|
| healthy | status | optional | All instances are responding normally. |
| degraded | status | optional | Some instances are slow or intermittently failing. |
| unhealthy | status | optional | The app is not responding or consistently failing. |
| unknown | status | optional | Health data is not yet available (new deploy or data gap). |
curl -X GET "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/apps/{appId}/health" \
-H "Authorization: Bearer dor_sk_your_key_here"App Logs
/workspaces/{wsId}/monitoring/apps/{appId}/logsReturns paginated log entries from Loki for a specific app. Use nextPageToken to paginate through large result sets.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | optional | Number of log entries to return. Default: 100. |
| severity | string | optional | Filter by severity level: DEBUG | INFO | WARNING | ERROR | CRITICAL. |
| pageToken | string | optional | Pagination cursor from a previous response. |
| startTime | string (ISO 8601) | optional | Return logs after this timestamp. |
| endTime | string (ISO 8601) | optional | Return logs before this timestamp. |
Response
{
"logs": [
{
"timestamp": "2025-01-20T14:30:01.123Z",
"severity": "INFO",
"message": "Server listening on port 3000"
},
{
"timestamp": "2025-01-20T14:30:05.456Z",
"severity": "ERROR",
"message": "Unhandled exception: Cannot read property 'id' of undefined"
}
],
"nextPageToken": "CjISEA..."
}curl -X GET "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/apps/{appId}/logs?limit=50&severity=ERROR" \
-H "Authorization: Bearer dor_sk_your_key_here"Stream Logs (SSE)
/workspaces/{wsId}/monitoring/apps/{appId}/logs/streamStreams live log output from a running app using Server-Sent Events (SSE). The connection stays open and new log lines are pushed as they arrive.
Content-Type: text/event-stream. Use the browser EventSource API or an SSE client library. The connection is kept alive until the client closes it or the app stops.# Connect to the log stream
curl -N -X GET "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/apps/{appId}/logs/stream" \
-H "Authorization: Bearer dor_sk_your_key_here" \
-H "Accept: text/event-stream"
# Example event output:
# data: {"timestamp":"2025-01-20T14:30:01Z","severity":"INFO","message":"Request received"}
# data: {"timestamp":"2025-01-20T14:30:02Z","severity":"INFO","message":"Response sent in 42ms"}// Browser EventSource example
const url = "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/apps/{appId}/logs/stream"
const source = new EventSource(url, {
// Note: EventSource does not support custom headers natively.
// Use a token in the query string or a cookie-based auth flow.
})
source.onmessage = (event) => {
const log = JSON.parse(event.data)
console.log(`[${log.severity}] ${log.message}`)
}
source.onerror = () => {
source.close()
}Workspace Overview
/workspaces/{wsId}/monitoring/overviewReturns a high-level summary of the workspace - aggregate stats, health breakdown, and recent activity. Useful for dashboard home pages.
Response
{
"totalApps": 12,
"activeApps": 9,
"totalDeploys": 284,
"deploysToday": 7,
"failedBuildsToday": 1,
"estimatedMonthlyCost": 148.50,
"appHealthSummary": {
"healthy": 8,
"degraded": 1,
"unhealthy": 0,
"unknown": 3
},
"recentActivity": [
{
"type": "deploy",
"appName": "my-api",
"status": "succeeded",
"timestamp": "2025-01-20T14:00:00Z"
},
{
"type": "alert",
"appName": "worker-service",
"message": "High memory usage detected",
"timestamp": "2025-01-20T13:45:00Z"
}
]
}curl -X GET "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/overview" \
-H "Authorization: Bearer dor_sk_your_key_here"List Alerts
/workspaces/{wsId}/monitoring/alertsReturns monitoring alerts for the workspace. Alerts are triggered by threshold rules on CPU, memory, error rate, and latency.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| appId | string | optional | Filter alerts by app ID. |
| resolved | boolean | optional | Filter by resolution state. Default: returns all. |
| limit | integer | optional | Maximum alerts to return. Default: 50. |
Response
[
{
"id": "alr_01hx...",
"appId": "app_01hx...",
"appName": "worker-service",
"type": "high_memory",
"severity": "warning",
"message": "Memory usage exceeded 80% threshold",
"triggeredAt": "2025-01-20T13:45:00Z",
"resolvedAt": null,
"resolved": false
}
]curl -X GET "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/alerts?resolved=false" \
-H "Authorization: Bearer dor_sk_your_key_here"Resolve Alert
/workspaces/{wsId}/monitoring/alerts/{alertId}/resolveMarks an alert as resolved. Resolved alerts are still visible in the history but no longer appear in the active alerts list.
Response
{
"id": "alr_01hx...",
"appId": "app_01hx...",
"type": "high_memory",
"severity": "warning",
"message": "Memory usage exceeded 80% threshold",
"triggeredAt": "2025-01-20T13:45:00Z",
"resolvedAt": "2025-01-20T14:10:00Z",
"resolved": true
}curl -X PATCH "https://os-develop.dooor.ai/api/v1/workspaces/{wsId}/monitoring/alerts/{alertId}/resolve" \
-H "Authorization: Bearer dor_sk_your_key_here"