@@ -105,6 +105,8 @@ type ProjectSpec struct {
105105 ApplicationCategories []ApplicationCategorySpec `json:"applicationCategories,omitempty"`
106106 // Custom applications.
107107 CustomApplications []CustomApplicationSpec `json:"customApplications,omitempty"`
108+ // Alerting rules. Rules defined here are shown with a lock icon in the UI and cannot be edited or deleted through the UI.
109+ AlertingRules []AlertingRuleSpec `json:"alertingRules,omitempty"`
108110 // Inspection overrides.
109111 InspectionOverrides * InspectionOverrides `json:"inspectionOverrides,omitempty"`
110112}
@@ -266,6 +268,84 @@ type ApplicationCategoryNotificationSettingsWebhookSpec struct {
266268 Enabled bool `json:"enabled,omitempty"`
267269}
268270
271+ type AlertingRuleSpec struct {
272+ // Rule ID (required). For built-in rules, use the existing rule ID (e.g., storage-space, memory-pressure).
273+ // For custom rules, choose any unique ID. The ID is shown in the rule detail dialog.
274+ // +kubebuilder:validation:Required
275+ Id string `json:"id"`
276+ // Rule name.
277+ Name * string `json:"name,omitempty"`
278+ // Alert source configuration.
279+ Source * AlertSourceSpec `json:"source,omitempty"`
280+ // Application selector.
281+ Selector * AppSelectorSpec `json:"selector,omitempty"`
282+ // Severity level (warning or critical).
283+ // +kubebuilder:validation:Enum=warning;critical
284+ Severity * string `json:"severity,omitempty"`
285+ // How long the condition must be true before firing (e.g., 5m, 1h).
286+ // +kubebuilder:validation:Pattern="^[0-9]+[smhdwy]$"
287+ For * string `json:"for,omitempty"`
288+ // How long to keep firing after condition clears (e.g., 5m).
289+ // +kubebuilder:validation:Pattern="^[0-9]+[smhdwy]$"
290+ KeepFiringFor * string `json:"keepFiringFor,omitempty"`
291+ // Notification templates.
292+ Templates * AlertTemplatesSpec `json:"templates,omitempty"`
293+ // Override the notification category for this rule.
294+ NotificationCategory * string `json:"notificationCategory,omitempty"`
295+ // Whether the rule is enabled.
296+ Enabled * bool `json:"enabled,omitempty"`
297+ }
298+
299+ type AlertSourceSpec struct {
300+ // Source type: check, log_patterns, or promql.
301+ // +kubebuilder:validation:Enum=check;log_patterns;promql
302+ Type string `json:"type"`
303+ // Check source configuration (required if type is check).
304+ Check * CheckSourceSpec `json:"check,omitempty"`
305+ // Log pattern source configuration (required if type is log_patterns).
306+ LogPattern * LogPatternSourceSpec `json:"logPattern,omitempty"`
307+ // PromQL source configuration (required if type is promql).
308+ PromQL * PromQLSourceSpec `json:"promql,omitempty"`
309+ }
310+
311+ type CheckSourceSpec struct {
312+ // The inspection check ID (e.g., cpu-utilization, storage-space).
313+ CheckId string `json:"checkId"`
314+ }
315+
316+ type LogPatternSourceSpec struct {
317+ // Log severities to match (e.g., ["error", "fatal"]).
318+ Severities []string `json:"severities"`
319+ // Minimum number of occurrences before alerting.
320+ MinCount * int `json:"minCount,omitempty"`
321+ // Maximum number of alerts per application for this rule.
322+ MaxAlertsPerApp * int `json:"maxAlertsPerApp,omitempty"`
323+ // Use AI to evaluate log patterns and reduce noise.
324+ EvaluateWithAi * bool `json:"evaluateWithAi,omitempty"`
325+ }
326+
327+ type PromQLSourceSpec struct {
328+ // PromQL expression that triggers the alert when it returns results.
329+ Expression string `json:"expression"`
330+ }
331+
332+ type AppSelectorSpec struct {
333+ // Selector type: all, category, or applications.
334+ // +kubebuilder:validation:Enum=all;category;applications
335+ Type string `json:"type"`
336+ // Application categories to match (when type is category).
337+ Categories []string `json:"categories,omitempty"`
338+ // Application ID patterns to match (when type is applications).
339+ ApplicationIdPatterns []string `json:"applicationIdPatterns,omitempty"`
340+ }
341+
342+ type AlertTemplatesSpec struct {
343+ // Summary template.
344+ Summary string `json:"summary,omitempty"`
345+ // Description template.
346+ Description string `json:"description,omitempty"`
347+ }
348+
269349type CustomApplicationSpec struct {
270350 // Custom application name (required).
271351 Name string `json:"name"`
0 commit comments