Metrics API
Query and push metrics data.
Query Metrics
http
GET /api/v1/metricsQuery Parameters
| Parameter | Type | Description |
|---|---|---|
service | string | Service ID or name (required) |
metric | string | Metric name (e.g., cpu_percent, memory_mb) |
from | string | Start time (ISO 8601 or relative: -1h, -24h) |
to | string | End time (default: now) |
interval | string | Aggregation interval (1m, 5m, 1h) |
Example
bash
curl "https://ops.example.com/api/v1/metrics?service=api-gateway&metric=cpu_percent&from=-1h&interval=5m" \
-H "Authorization: Bearer $API_KEY"Response
json
{
"data": {
"service": "api-gateway",
"metric": "cpu_percent",
"unit": "percent",
"values": [
{ "timestamp": "2025-01-15T10:00:00Z", "value": 42.5 },
{ "timestamp": "2025-01-15T10:05:00Z", "value": 45.2 },
{ "timestamp": "2025-01-15T10:10:00Z", "value": 38.1 }
]
}
}Push Custom Metrics
http
POST /api/v1/metricsRequest Body
json
{
"service": "api-gateway",
"metrics": [
{
"name": "active_connections",
"value": 1250,
"timestamp": "2025-01-15T10:00:00Z"
},
{
"name": "queue_depth",
"value": 42
}
]
}Response
json
{
"data": {
"accepted": 2,
"rejected": 0
}
}Available Metrics
System Metrics
| Metric | Description | Unit |
|---|---|---|
cpu_percent | CPU usage | percent |
memory_mb | Memory usage | megabytes |
memory_percent | Memory usage | percent |
disk_percent | Disk usage | percent |
network_rx_bytes | Network received | bytes |
network_tx_bytes | Network transmitted | bytes |
Application Metrics
| Metric | Description | Unit |
|---|---|---|
requests_total | Total requests | count |
requests_per_sec | Request rate | requests/sec |
response_time_ms | Response latency | milliseconds |
error_rate | Error percentage | percent |