MATIH Platform is in active MVP development. Documentation reflects current implementation status.
7. Tenant Lifecycle
Resource Management
Resource Alerts

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

MethodPathDescription
GET/alertsGet paginated alerts (filter by status)
GET/alerts/activeGet all active alerts
GET/alerts/summaryGet alert summary statistics
GET/alerts/{alertId}Get specific alert
POST/alerts/{alertId}/acknowledgeAcknowledge an alert
POST/alerts/{alertId}/resolveResolve an alert
POST/alerts/{alertId}/suppressSuppress an alert

Alert Rule Endpoints

MethodPathDescription
GET/alerts/rulesList all alert rules
POST/alerts/rulesCreate 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}/enableEnable a rule
POST/alerts/rules/{ruleId}/disableDisable a rule

Alert Lifecycle

ACTIVE --> ACKNOWLEDGED --> RESOLVED
  |                           ^
  |                           |
  +-------> SUPPRESSED -------+

Alert Statuses

StatusDescription
ACTIVEAlert is firing and requires attention
ACKNOWLEDGEDAlert has been seen by an operator
RESOLVEDAlert condition is no longer true
SUPPRESSEDAlert 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

FilePath
Controllercontrol-plane/tenant-service/src/main/java/com/matih/tenant/controller/ResourceAlertController.java
Servicecontrol-plane/tenant-service/src/main/java/com/matih/tenant/service/ResourceAlertService.java
Alert Entitycontrol-plane/tenant-service/src/main/java/com/matih/tenant/entity/ResourceAlert.java
Rule Entitycontrol-plane/tenant-service/src/main/java/com/matih/tenant/entity/AlertRule.java