Resource Alerts
The ResourceAlertController at /api/v1/tenants/{tenantId}/alerts manages resource consumption alerts and configurable alert rules. Alerts are triggered by the quota system when usage thresholds are crossed.
Alert Endpoints
| Method | Path | Description |
|---|---|---|
GET | /alerts | Get paginated alerts (filter by status) |
GET | /alerts/active | Get all active alerts |
GET | /alerts/summary | Get alert summary statistics |
GET | /alerts/{alertId} | Get specific alert |
POST | /alerts/{alertId}/acknowledge | Acknowledge an alert |
POST | /alerts/{alertId}/resolve | Resolve an alert |
POST | /alerts/{alertId}/suppress | Suppress an alert |
Alert Rule Endpoints
| Method | Path | Description |
|---|---|---|
GET | /alerts/rules | List all alert rules |
POST | /alerts/rules | Create an alert rule |
GET | /alerts/rules/{ruleId} | Get specific rule |
PUT | /alerts/rules/{ruleId} | Update an alert rule |
DELETE | /alerts/rules/{ruleId} | Delete an alert rule |
POST | /alerts/rules/{ruleId}/enable | Enable a rule |
POST | /alerts/rules/{ruleId}/disable | Disable a rule |
Alert Lifecycle
ACTIVE --> ACKNOWLEDGED --> RESOLVED
| ^
| |
+-------> SUPPRESSED -------+Alert Statuses
| Status | Description |
|---|---|
ACTIVE | Alert is firing and requires attention |
ACKNOWLEDGED | Alert has been seen by an operator |
RESOLVED | Alert condition is no longer true |
SUPPRESSED | Alert is temporarily silenced |
Listing Alerts
# All alerts (paginated, sorted by most recent)
curl "http://localhost:8082/api/v1/tenants/{tenantId}/alerts?page=0&size=20" \
-H "Authorization: Bearer $TOKEN"
# Filter by status
curl "http://localhost:8082/api/v1/tenants/{tenantId}/alerts?status=ACTIVE&page=0&size=20" \
-H "Authorization: Bearer $TOKEN"
# Active alerts only (unpaginated)
curl http://localhost:8082/api/v1/tenants/{tenantId}/alerts/active \
-H "Authorization: Bearer $TOKEN"Alert Summary
curl http://localhost:8082/api/v1/tenants/{tenantId}/alerts/summary \
-H "Authorization: Bearer $TOKEN"Returns an AlertSummary with counts by status, severity, and resource type.
Acknowledging an Alert
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/alerts/{alertId}/acknowledge \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"userId": "c9d0e1f2-..."
}'Resolving an Alert
@Data
public static class ResolveRequest {
private UUID userId;
private ResolutionType resolutionType; // MANUAL, AUTOMATIC, TIMEOUT
private String notes;
}curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/alerts/{alertId}/resolve \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"userId": "c9d0e1f2-...",
"resolutionType": "MANUAL",
"notes": "Increased storage quota to resolve disk pressure alert"
}'Suppressing an Alert
Temporarily silence an alert without resolving the underlying condition:
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/alerts/{alertId}/suppress \
-H "Authorization: Bearer $TOKEN"Returns 204 No Content.
Creating Alert Rules
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/alerts/rules \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ruleName": "High CPU Usage",
"resourceType": "CPU",
"condition": "GREATER_THAN",
"threshold": 80.0,
"severity": "WARNING",
"evaluationPeriod": "5m",
"notificationChannels": ["email", "slack"],
"enabled": true
}'Response (201 Created): Returns the created AlertRule.
Returns 409 Conflict if a rule with the same name already exists.
Managing Alert Rules
Update a Rule
curl -X PUT http://localhost:8082/api/v1/tenants/{tenantId}/alerts/rules/{ruleId} \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"threshold": 90.0,
"severity": "CRITICAL"
}'Enable/Disable a Rule
# Enable
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/alerts/rules/{ruleId}/enable \
-H "Authorization: Bearer $TOKEN"
# Disable
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/alerts/rules/{ruleId}/disable \
-H "Authorization: Bearer $TOKEN"Delete a Rule
curl -X DELETE http://localhost:8082/api/v1/tenants/{tenantId}/alerts/rules/{ruleId} \
-H "Authorization: Bearer $TOKEN"Returns 204 No Content.
Source Files
| File | Path |
|---|---|
| Controller | control-plane/tenant-service/src/main/java/com/matih/tenant/controller/ResourceAlertController.java |
| Service | control-plane/tenant-service/src/main/java/com/matih/tenant/service/ResourceAlertService.java |
| Alert Entity | control-plane/tenant-service/src/main/java/com/matih/tenant/entity/ResourceAlert.java |
| Rule Entity | control-plane/tenant-service/src/main/java/com/matih/tenant/entity/AlertRule.java |