Metrics and Logs
Learn how to get metrics and logs from your project via API.
Get Project Metrics
Returns the usage metrics of the project (CPU, memory, etc).
GET /project/:id/metricsPath Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Project ID (ObjectId) |
Response
{
"status": "success",
"data": {
"cpu_usage": "250m",
"memory_usage": "512Mi",
"cpu_limit": "1000m",
"memory_limit": "1Gi",
"replicas": 2,
"uptime": "24h30m"
}
}Get Project Logs
Returns the logs of the running project.
GET /project/:id/logsPath Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Project ID (ObjectId) |
Query Parameters (optional)
| Parameter | Type | Description |
|---|---|---|
lines | number | Number of log lines (default: 100) |
container | string | Specific container name |
Response
{
"status": "success",
"data": {
"logs": [
"2024-01-15T10:30:00Z Starting application...",
"2024-01-15T10:30:01Z Server listening on port 3000",
"2024-01-15T10:30:05Z GET /health 200"
]
}
}Examples
Get Metrics
curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/metrics" \
-H "x-api-key: your-api-key"Get Logs
curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/logs?lines=50" \
-H "x-api-key: your-api-key"Python
import requests
API_KEY = "your-api-key"
PROJECT_ID = "507f1f77bcf86cd799439011"
headers = {"x-api-key": API_KEY}
# Get metrics
metrics = requests.get(
f"https://api.zenifra.com/v1/project/{PROJECT_ID}/metrics",
headers=headers
).json()
print(metrics)
# Get logs
logs = requests.get(
f"https://api.zenifra.com/v1/project/{PROJECT_ID}/logs",
params={"lines": 50},
headers=headers
).json()
print(logs)