Skip to content

Commit 87d1e4c

Browse files
authored
Merge pull request #33 from coroot/alerting_rules
add alertingRules and disableBuiltinAlerts fields to the CRD
2 parents 6b8eb2a + 56e9c73 commit 87d1e4c

6 files changed

Lines changed: 559 additions & 9 deletions

File tree

api/v1/config.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
269349
type CustomApplicationSpec struct {
270350
// Custom application name (required).
271351
Name string `json:"name"`

api/v1/coroot_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ type CorootSpec struct {
319319

320320
// Coroot Cloud integration.
321321
CorootCloud *CorootCloudSpec `json:"corootCloud,omitempty"`
322+
// Disable all built-in alerting rules on startup.
323+
DisableBuiltinAlerts bool `json:"disableBuiltinAlerts,omitempty"`
322324
// Projects configuration (Coroot will create or update the specified projects).
323325
Projects []ProjectSpec `json:"projects,omitempty"`
324326
// Single Sign-On configuration (Coroot Enterprise Edition only).

api/v1/zz_generated.deepcopy.go

Lines changed: 202 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)