Alerting: Add recording rules to ruler API and validation (#87779)
* Read path, main API * Define record field for incoming requests * Refactor several alerting specific validators into two paths * Refactor validateCondition actually contain all the condition validation logic * Move condition validation inside rule path * Validators for recording rules * Wire feature flag through to validators * Test for accepting a valid recording rule * Tests for negative case, no UID * Test for ignoring alerting fields * Build conditions based on recording rules as well * Regenerate swagger docs * Fix CRUD test to cover the right thing * Re-generate swagger docs with backdated v0.30.2 version * Regenerate base spec * Regenerate ngalert specs * Regenerate top level specs * Comment and rename * Return struct instead of modifying ref
This commit is contained in:
@@ -487,6 +487,7 @@ type PostableGrafanaRule struct {
|
||||
ExecErrState ExecutionErrorState `json:"exec_err_state" yaml:"exec_err_state"`
|
||||
IsPaused *bool `json:"is_paused" yaml:"is_paused"`
|
||||
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings" yaml:"notification_settings"`
|
||||
Record *Record `json:"record" yaml:"record"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
@@ -507,6 +508,7 @@ type GettableGrafanaRule struct {
|
||||
Provenance Provenance `json:"provenance,omitempty" yaml:"provenance,omitempty"`
|
||||
IsPaused bool `json:"is_paused" yaml:"is_paused"`
|
||||
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings,omitempty" yaml:"notification_settings,omitempty"`
|
||||
Record *Record `json:"record,omitempty" yaml:"record,omitempty"`
|
||||
}
|
||||
|
||||
// AlertQuery represents a single query associated with an alert definition.
|
||||
@@ -576,6 +578,12 @@ func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Record defines how data produced by a recording rule is written.
|
||||
type Record struct {
|
||||
Metric string `json:"metric" yaml:"metric"`
|
||||
From string `json:"from" yaml:"from"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type UpdateRuleGroupResponse struct {
|
||||
Message string `json:"message"`
|
||||
|
||||
Reference in New Issue
Block a user