VM Autoscaling
Autoscaler policies right-size VM fleets automatically based on utilization metrics and schedule triggers. One policy targets one cloud account + resource selector (tag, group, or a specific autoscaling group/instance-pool) and runs in one of three modes.
Modes
The mode is auto-derived from the credential's permission verdict (see Cloud Accounts). You can downgrade a policy's effective mode but not upgrade it past what the credential can do.
| Mode | Required permission | Behaviour |
|---|---|---|
monitor | read-only | Collects metrics and publishes what-if recommendations. No cloud writes. |
recommend | read-write | Generates recommendations with a one-click apply button. No automatic writes. |
autopilot | read-write | Applies changes automatically within the configured min/max/cooldown. |
Quick Setup (Smart Defaults)
Pick a cloud account and target, and ZopNight fills in sensible min/max/target and cooldown values based on the last 14 days of utilization.
/autoscaler-policies/smart-defaultsFetch smart defaults for a target before creating a policy.
Query Parameters
| Parameter | Description |
|---|---|
cloud_account_id | The cloud account hosting the target |
target_type | aws-asg, ecs-service, gcp-mig, azure-vmss, azure-databricks-instance-pool, etc. |
target_uid | Native identifier of the scaling target |
{
"data": {
"min": 2,
"max": 10,
"targetCPUPercent": 60,
"cooldownSeconds": 300,
"basedOn": {
"windowDays": 14,
"p95CPUPercent": 58,
"peakInstances": 9
}
}
}Create Policy
/autoscaler-policiesCreate an autoscaler policy.
curl -X POST https://zopnight.com/api/autoscaler-policies \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "web-tier autoscaler",
"mode": "recommend",
"cloudAccountID": "ca_abc123",
"target": {
"type": "aws-asg",
"uid": "arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:...:autoScalingGroupName/web"
},
"min": 2,
"max": 10,
"targetCPUPercent": 60,
"cooldownSeconds": 300,
"triggers": [
{ "preset": "business-hours", "timezone": "America/New_York" }
]
}'Schedule Triggers
Autoscaler policies can be shaped by schedule triggers layered on top of the utilization loop. Three presets are built in:
| Preset | What it does |
|---|---|
business-hours | Raises min capacity Mon–Fri 08:00–18:00 in the configured timezone |
peak-hours | Raises min capacity during a custom window (typically retail peaks / report runs) |
weekend-scale-down | Lowers min capacity Sat/Sun so the utilization loop can shrink the fleet |
One-click from recommendations
RC-ASC-001..RC-ASC-006 propose autoscaler policies for likely targets. Applying one of those recommendations creates a policy in recommend mode so nothing writes to the cloud until you review it.ECS Services — Adopt or Replace
ZopNight extends the same autoscaler model to AWS ECS services. The wizard inspects existing AWS Application Auto Scaling policies on the target service before doing anything and offers two paths:
- Adopt — ZopNight takes over the existing scaling policies. Existing min/max are preserved and the schedule wraps around them. Nothing is recreated.
- Replace — existing policies are removed and ZopNight installs its own. Used when the existing policies don't match your current traffic shape.
/autoscaler-policies/existing-policiesInspect existing AWS Application Auto Scaling policies on an ECS service before deciding adopt vs replace.
Query: ?target_type=ecs-service&target_uid=service/cluster-prod/api
{
"data": {
"policies": [
{
"policyName": "scale-up-on-cpu",
"metric": "ECSServiceAverageCPUUtilization",
"target": 60,
"managedBy": "user"
}
],
"recommendation": "adopt"
}
}Source-aware tolerance
Provision the Autoscaler Infrastructure
Before the first autopilot policy can write to your cloud account, ZopNight needs a small footprint of cloud-side resources (an IAM role + Lambda / Cloud Run shim that the metrics loop calls into). Provisioning is one-time per cloud account.
/autoscaler-policies/required-permissionsList the IAM permissions ZopNight needs to provision the autoscaler infrastructure for a given cloud account.
{
"data": {
"provider": "aws",
"permissions": [
"iam:CreateRole",
"iam:AttachRolePolicy",
"lambda:CreateFunction",
"lambda:UpdateFunctionCode",
"events:PutRule"
]
}
}/autoscaler-policies/create-infrastructureProvision the cloud-side infrastructure for a cloud account.
curl -X POST https://zopnight.com/api/autoscaler-policies/create-infrastructure \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{ "cloudAccountID": "ca_abc123" }'/autoscaler-policies/infrastructure-statusCheck provisioning status for a cloud account. Poll while a create-infrastructure request is in flight.
{
"data": {
"cloudAccountID": "ca_abc123",
"status": "ready",
"createdAt": "2026-04-29T08:00:00Z",
"components": {
"role": "arn:aws:iam::123456789012:role/zopnight-autoscaler",
"runtime": "arn:aws:lambda:us-east-1:123456789012:function:zopnight-autoscaler-shim"
}
}
}Lifecycle
/autoscaler-policies/{policyID}/applyApply the latest recommendation from a recommend-mode policy.
/autoscaler-policies/{policyID}/pausePause evaluation. No recommendations or writes are produced.
/autoscaler-policies/{policyID}/resumeResume a paused policy.
/autoscaler-policies/{policyID}/removeTombstone the policy (soft delete). Past events remain visible.
Policy Events
/autoscaler-policies/{policyID}/eventsPer-policy event log: recommendations, applies, pauses, writes, failures.
{
"data": [
{
"id": "ev_001",
"kind": "recommendation",
"fromMin": 2, "fromMax": 10,
"toMin": 4, "toMax": 12,
"reason": "p95 CPU 72% over last 4h",
"appliedBy": null,
"createdAt": "2026-04-20T09:30:00Z"
},
{
"id": "ev_002",
"kind": "apply",
"toMin": 4, "toMax": 12,
"appliedBy": "user@company.com",
"createdAt": "2026-04-20T09:31:12Z"
}
]
}List & Filters
/autoscaler-policiesList policies with filter/sort/pagination.
/autoscaler-policies/countCount policies grouped by status.
/autoscaler-policies/filtersDistinct filter values (modes, targets, cloud accounts) for building UIs.
/autoscaler-policies/{policyID}Get a single policy, including latest recommendation and current target state.
/autoscaler-policies/{policyID}Update min/max/target/cooldown/triggers. Does not switch mode.
/autoscaler-policies/{policyID}Delete a policy (same effect as /remove).