Get Project Metrics

Returns the usage metrics of the project (CPU, memory, etc).

GET /project/:id/metrics

Path Parameters

ParameterTypeDescription
idstringProject ID (ObjectId)

Headers

HeaderRequiredDescription
x-api-keyYesProject API Key
x-organization-idYesActive project organization

Query Parameters (optional)

ParameterTypeDescription
instancestringSpecific instance identifier. When omitted, HTTP projects return aggregated network metrics.

Response

The uptime field represents the current instance or container uptime returned by the metrics endpoint. It should not be interpreted as application uptime, SLA, or public availability history.

{
  "status": "success",
  "message": "get metrics with success",
  "data": {
    "type": "application",
    "aggregate": true,
    "network": {
      "requests": 1200,
      "bytes_received": 420000,
      "bytes_sent": 1800000,
      "status_codes": {
        "200": 1160,
        "500": 5
      },
      "user_agents": {
        "Mozilla/5.0": 900,
        "curl/8.0": 300
      },
      "window_seconds": 300
    }
  }
}

Get Project Logs

Returns the logs of the running project.

GET /project/:id/logs

Path Parameters

ParameterTypeDescription
idstringProject ID (ObjectId)

Query Parameters (optional)

ParameterTypeDescription
instancestringInstance identifier used to return logs from a single container

Response

{
  "status": "success",
  "message": "get instances logs with success",
  "data": [
    "2024-01-15T10:30:00Z Starting application...\n2024-01-15T10:30:01Z Server listening on port 3000",
    "2024-01-15T10:30:05Z GET /health 200"
  ]
}

When instance is sent, data can be a single string containing the logs for the requested instance.


Examples

Get Metrics

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/metrics" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"

Get Logs

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/logs?instance=abc" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"

Python

import requests

API_KEY = "your-api-key"
ORGANIZATION_ID = "your-organization-id"
PROJECT_ID = "507f1f77bcf86cd799439011"

headers = {"x-api-key": API_KEY, "x-organization-id": ORGANIZATION_ID}

# 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={"instance": "abc"},
    headers=headers
).json()
print(logs)