110 group_ = std::move(group_name);
273 "Rule name cannot be empty");
278 "Rule configuration is invalid");
283 "Rule must have a trigger");
377 rule->set_group(
name_);
378 rules_.push_back(std::move(rule));
386 const std::vector<std::shared_ptr<alert_rule>>&
rules()
const {
408 for (
auto& rule :
rules_) {
409 rule->set_evaluation_interval(interval);
423 std::vector<std::shared_ptr<alert_rule>>
rules_;
Core alert data structures for the monitoring system.
A group of related alert rules.
std::optional< std::chrono::milliseconds > common_interval() const
Get common evaluation interval.
std::optional< std::chrono::milliseconds > common_interval_
bool empty() const
Check if group is empty.
alert_rule_group(std::string name)
Construct a rule group.
size_t size() const
Get number of rules.
void set_common_interval(std::chrono::milliseconds interval)
Set common evaluation interval for all rules.
std::vector< std::shared_ptr< alert_rule > > rules_
void add_rule(std::shared_ptr< alert_rule > rule)
Add a rule to the group.
const std::string & name() const
Get group name.
const std::vector< std::shared_ptr< alert_rule > > & rules() const
Get all rules in the group.
Defines conditions and behavior for alert triggering.
const alert_rule_config & config() const
Get configuration.
alert_rule & set_evaluation_interval(std::chrono::milliseconds interval)
Set evaluation interval.
alert_rule & set_trigger(std::shared_ptr< alert_trigger > trigger)
Set the trigger for this rule.
std::shared_ptr< alert_trigger > trigger() const
Get the trigger.
alert_rule(std::string name)
Construct an alert rule with a name.
const std::string & group() const
Get rule group.
const std::string & name() const
Get rule name.
std::shared_ptr< alert_trigger > trigger_
const alert_annotations & annotations() const
Get annotations.
alert_rule & set_group(std::string group_name)
Set rule group.
common::VoidResult validate() const
Validate rule configuration.
alert_rule & set_summary(std::string summary)
Set alert summary.
alert create_alert(double value) const
Create an alert from this rule.
alert_rule & set_for_duration(std::chrono::milliseconds duration)
Set for duration (pending time before firing)
const std::string & metric_name() const
Get metric name to monitor.
alert_rule_config config_
alert_rule & set_description(std::string description)
Set alert description.
alert_rule & set_enabled(bool enabled)
Enable or disable rule.
alert_rule & set_severity(alert_severity sev)
Set alert severity.
bool is_enabled() const
Check if rule is enabled.
alert_severity severity() const
Get alert severity.
alert_rule & set_runbook_url(std::string url)
Set runbook URL.
alert_rule & add_label(const std::string &key, const std::string &value)
Add a label.
alert_annotations annotations_
alert_rule & set_repeat_interval(std::chrono::milliseconds interval)
Set notification repeat interval.
const alert_labels & labels() const
Get labels.
alert_rule & set_metric_name(std::string name)
Set metric name to monitor.
Base class for alert trigger conditions.
virtual std::string description() const =0
Get human-readable description.
virtual ~alert_trigger()=default
virtual bool evaluate(double value) const =0
Evaluate the trigger condition.
virtual std::string type_name() const =0
Get trigger type name.
@ summary
Pre-calculated quantiles and count/sum.
alert_severity
Severity levels for alerts.
@ warning
Warning condition, may require attention.
Result pattern type definitions for monitoring system.
Additional metadata for alert context.
std::string description
Detailed description.
std::string summary
Brief description.
std::optional< std::string > runbook_url
Link to runbook.
Key-value labels for alert identification and routing.
void set(const std::string &key, const std::string &value)
Add or update a label.
Configuration for an alert rule.
bool validate() const
Validate configuration.
std::chrono::milliseconds for_duration
Duration before firing.
std::chrono::milliseconds keep_firing_duration
Duration to keep firing.
bool keep_firing_for
Keep firing after resolve.
std::chrono::milliseconds repeat_interval
Notification repeat interval.
std::chrono::milliseconds evaluation_interval
How often to evaluate.
Core alert data structure.
double value
Current metric value.
alert_severity severity
Alert severity level.
std::string rule_name
Name of triggering rule.
std::string group_key
Grouping key for dedup.
alert_annotations annotations
Descriptive annotations.
Extended error information with context.
common::error_info to_common_error() const
Convert to common_system error_info.