App Environment Metrics API
The App Environment Metrics API allows you to retrieve real-time resource usage metrics (CPU, memory, containers) for an app environment in Quave Cloud.
Make sure to read the Get Started document to understand how the API works.
Note: This API endpoint accepts only user tokens (not environment tokens).
Get App Environment Metrics
To retrieve metrics for an app environment, send a GET request to the /api/public/v1/app-env/metrics endpoint.
You need to provide either appEnvId or envName to identify the environment.
Required Parameters (Either/Or)
You must provide either appEnvId or envName:
| Parameter | Type | Description |
|---|---|---|
appEnvId | String | The ID of the app environment to retrieve metrics for. |
envName | String | The CLI environment name (alternative to appEnvId). |
Response Structure
The response is a JSON object with the following fields:
| Field | Type | Description |
|---|---|---|
appEnvId | String | The app environment ID. |
timestamp | Date | Timestamp when metrics were retrieved. |
resources | Object | CPU and memory usage metrics (see below). |
containers | Object | Container count and status (see below). |
autoScaling | Object | Autoscaling configuration (see below). |
Resources Object
The resources object contains CPU and memory metrics:
{
"cpu": {
"allocated": 1.0, // CPU cores allocated
"used": 0.65, // CPU cores currently in use
"usagePercent": 65, // Usage percentage (0-100)
"updatedAt": "2024-01-15T10:30:00.000Z" // Last metric update
},
"memory": {
"allocated": 512, // Memory allocated in MB
"used": 380, // Memory currently in use in MB
"usagePercent": 74, // Usage percentage (0-100)
"updatedAt": "2024-01-15T10:30:00.000Z" // Last metric update
}
}
Containers Object
The containers object provides information about running pods:
| Field | Type | Description |
|---|---|---|
desired | Number | Desired number of containers/replicas. |
running | Number | Number of containers currently running. |
ready | Number | Number of containers that are ready. |
updatedAt | Date | Last update timestamp (null if no data available). |
AutoScaling Object
The autoScaling object describes autoscaling configuration:
When autoscaling is enabled:
{
"enabled": true,
"minReplicas": 1, // Minimum number of replicas
"maxReplicas": 4, // Maximum number of replicas
"currentReplicas": 2, // Current replica count
"targetCPU": 70, // Target CPU utilization percentage (null if not set)
"targetMemory": 80 // Target memory utilization percentage (null if not set)
}
When autoscaling is disabled:
{
"enabled": false
}
Example: Get Metrics (with appEnvId)
curl -X GET \
-H 'Authorization: YOUR_TOKEN' \
'https://api.quave.cloud/api/public/v1/app-env/metrics?appEnvId=5f7b1b7b7b7b7b7b7b7b7b7b'
Example: Get Metrics (with envName)
curl -X GET \
-H 'Authorization: YOUR_TOKEN' \
'https://api.quave.cloud/api/public/v1/app-env/metrics?envName=production'
Example Response
{
"appEnvId": "5f7b1b7b7b7b7b7b7b7b7b7b",
"timestamp": "2024-01-15T10:30:00.000Z",
"resources": {
"cpu": {
"allocated": 1.0,
"used": 0.65,
"usagePercent": 65,
"updatedAt": "2024-01-15T10:29:45.000Z"
},
"memory": {
"allocated": 512,
"used": 380,
"usagePercent": 74,
"updatedAt": "2024-01-15T10:29:45.000Z"
}
},
"containers": {
"desired": 2,
"running": 2,
"ready": 2,
"updatedAt": "2024-01-15T10:29:50.000Z"
},
"autoScaling": {
"enabled": true,
"minReplicas": 1,
"maxReplicas": 4,
"currentReplicas": 2,
"targetCPU": 70,
"targetMemory": 80
}
}
Use Cases
This endpoint is useful for:
- Performance Monitoring - Track CPU and memory usage in real-time
- Capacity Planning - Understand resource utilization patterns
- Alerting - Set up alerts based on resource thresholds
- Autoscaling Decisions - See how autoscaling is performing
- Cost Optimization - Identify over-provisioned or under-utilized resources
Understanding Metrics
CPU Metrics:
allocatedis the total CPU cores assigned to the environmentusedis the current CPU usage across all containersusagePercentis calculated as (used / allocated) * 100
Memory Metrics:
allocatedis the total memory (MB) assigned to the environmentusedis the current memory consumption across all containersusagePercentis calculated as (used / allocated) * 100
Container Metrics:
desiredis the configured replica count (or autoscaler's current target)runningis the number of pods that are currently runningreadyis the number of pods that have passed health checks- If
running<desired, containers may be starting or failed
Autoscaling:
- When enabled, the autoscaler adjusts
currentReplicasbased ontargetCPUandtargetMemory - Replicas will scale between
minReplicasandmaxReplicas - If
targetCPUortargetMemoryisnull, that metric is not used for scaling decisions
Metric Freshness
- Metrics are typically updated every 30-60 seconds
- The
updatedAtfields show when each metric was last updated - If
updatedAtisnull, that metric has not been collected yet (new environment)
Error Responses
400- Missing required parameters (neitherappEnvIdnorenvNameprovided)401- User not authenticated403- User doesn't have permission to access this app environment404- App environment not found for the givenappEnvIdorenvName
Notes
Environment Identification:
- You can use either
appEnvIdorenvNameto identify the environment - If both are provided,
appEnvIdtakes precedence
Zero Values:
- If metrics show 0% usage, the environment may be stopped or metrics collection hasn't started
- New environments may take a few minutes to report metrics
High Usage:
- Consistently high CPU/memory usage (>80%) may indicate need for more resources
- If
running<desiredwith high usage, containers may be crashing due to resource limits