|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Defines conditions and behavior for alert triggering. More...
#include <alert_rule.h>

Public Member Functions | |
| alert_rule (std::string name) | |
| Construct an alert rule with a name. | |
| const std::string & | name () const |
| Get rule name. | |
| const std::string & | group () const |
| Get rule group. | |
| alert_rule & | set_group (std::string group_name) |
| Set rule group. | |
| alert_severity | severity () const |
| Get alert severity. | |
| alert_rule & | set_severity (alert_severity sev) |
| Set alert severity. | |
| const alert_labels & | labels () const |
| Get labels. | |
| alert_rule & | add_label (const std::string &key, const std::string &value) |
| Add a label. | |
| const alert_annotations & | annotations () const |
| Get annotations. | |
| alert_rule & | set_summary (std::string summary) |
| Set alert summary. | |
| alert_rule & | set_description (std::string description) |
| Set alert description. | |
| alert_rule & | set_runbook_url (std::string url) |
| Set runbook URL. | |
| const alert_rule_config & | config () const |
| Get configuration. | |
| alert_rule & | set_evaluation_interval (std::chrono::milliseconds interval) |
| Set evaluation interval. | |
| alert_rule & | set_for_duration (std::chrono::milliseconds duration) |
| Set for duration (pending time before firing) | |
| alert_rule & | set_repeat_interval (std::chrono::milliseconds interval) |
| Set notification repeat interval. | |
| bool | is_enabled () const |
| Check if rule is enabled. | |
| alert_rule & | set_enabled (bool enabled) |
| Enable or disable rule. | |
| 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 | create_alert (double value) const |
| Create an alert from this rule. | |
| common::VoidResult | validate () const |
| Validate rule configuration. | |
| const std::string & | metric_name () const |
| Get metric name to monitor. | |
| alert_rule & | set_metric_name (std::string name) |
| Set metric name to monitor. | |
Private Attributes | |
| std::string | name_ |
| std::string | group_ |
| std::string | metric_name_ |
| alert_severity | severity_ = alert_severity::warning |
| alert_labels | labels_ |
| alert_annotations | annotations_ |
| alert_rule_config | config_ |
| bool | enabled_ |
| std::shared_ptr< alert_trigger > | trigger_ |
Defines conditions and behavior for alert triggering.
An alert rule encapsulates the logic for when alerts should be triggered, how they should be labeled and annotated, and where notifications should be routed.
Definition at line 82 of file alert_rule.h.
|
inlineexplicit |
Construct an alert rule with a name.
| name | Unique rule name |
Definition at line 88 of file alert_rule.h.
|
inline |
Add a label.
| key | Label key |
| value | Label value |
Definition at line 142 of file alert_rule.h.
References labels_, and kcenon::monitoring::alert_labels::set().
Referenced by main(), TEST(), and TEST().


|
inline |
Get annotations.
Definition at line 151 of file alert_rule.h.
References annotations_.
Referenced by TEST().

|
inline |
Get configuration.
Definition at line 187 of file alert_rule.h.
References config_.
|
inline |
Create an alert from this rule.
| value | Current metric value |
Definition at line 256 of file alert_rule.h.
References kcenon::monitoring::alert::annotations, annotations_, group_, kcenon::monitoring::alert::group_key, labels_, name_, kcenon::monitoring::alert::rule_name, kcenon::monitoring::alert::severity, severity_, and kcenon::monitoring::alert::value.
Referenced by TEST(), and TEST().

|
inline |
Get rule group.
Definition at line 102 of file alert_rule.h.
References group_.
Referenced by TEST().

|
inline |
Check if rule is enabled.
Definition at line 223 of file alert_rule.h.
References enabled_.
Referenced by TEST(), and TEST().

|
inline |
Get labels.
Definition at line 134 of file alert_rule.h.
References labels_.
Referenced by TEST().

|
inline |
Get metric name to monitor.
Definition at line 293 of file alert_rule.h.
References metric_name_.
Referenced by TEST().

|
inline |
Get rule name.
Definition at line 96 of file alert_rule.h.
References name_.
Referenced by main(), set_metric_name(), and TEST().

|
inline |
Set alert description.
| description | Description text |
Definition at line 168 of file alert_rule.h.
References annotations_, and kcenon::monitoring::alert_annotations::description.
Referenced by main(), and TEST().

|
inline |
Enable or disable rule.
| enabled | Enable state |
Definition at line 230 of file alert_rule.h.
References enabled_.
Referenced by TEST(), and TEST().

|
inline |
Set evaluation interval.
| interval | Evaluation interval |
Definition at line 194 of file alert_rule.h.
References config_, and kcenon::monitoring::alert_rule_config::evaluation_interval.
Referenced by TEST(), and TEST().

|
inline |
Set for duration (pending time before firing)
| duration | Duration before firing |
Definition at line 204 of file alert_rule.h.
References config_, and kcenon::monitoring::alert_rule_config::for_duration.
Referenced by TEST().

|
inline |
Set rule group.
| group_name | Group name |
Definition at line 109 of file alert_rule.h.
References group_.
Referenced by TEST(), and TEST().

|
inline |
Set metric name to monitor.
| name | Metric name |
Definition at line 300 of file alert_rule.h.
References metric_name_, and name().
Referenced by main(), TEST(), and TEST().


|
inline |
Set notification repeat interval.
| interval | Repeat interval |
Definition at line 214 of file alert_rule.h.
References config_, and kcenon::monitoring::alert_rule_config::repeat_interval.
Referenced by TEST().

|
inline |
Set runbook URL.
| url | Runbook URL |
Definition at line 178 of file alert_rule.h.
References annotations_, and kcenon::monitoring::alert_annotations::runbook_url.
Referenced by TEST().

|
inline |
Set alert severity.
| sev | Severity level |
Definition at line 125 of file alert_rule.h.
References severity_.
Referenced by main(), TEST(), and TEST().

|
inline |
Set alert summary.
| summary | Summary text |
Definition at line 158 of file alert_rule.h.
References annotations_, kcenon::monitoring::alert_annotations::summary, and kcenon::monitoring::summary.
Referenced by main(), TEST(), and TEST().

|
inline |
Set the trigger for this rule.
| trigger | Trigger implementation |
Definition at line 240 of file alert_rule.h.
References trigger(), and trigger_.
Referenced by main(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().


|
inline |
Get alert severity.
Definition at line 118 of file alert_rule.h.
References severity_.
Referenced by TEST(), and TEST().

|
inline |
Get the trigger.
Definition at line 249 of file alert_rule.h.
References trigger_.
Referenced by main(), set_trigger(), and TEST().

|
inline |
Validate rule configuration.
Definition at line 270 of file alert_rule.h.
References config_, kcenon::monitoring::invalid_argument, kcenon::monitoring::invalid_configuration, name_, kcenon::monitoring::error_info::to_common_error(), trigger_, and kcenon::monitoring::alert_rule_config::validate().
Referenced by main(), TEST(), TEST(), TEST(), and TEST().


|
private |
Definition at line 311 of file alert_rule.h.
Referenced by annotations(), create_alert(), set_description(), set_runbook_url(), and set_summary().
|
private |
Definition at line 312 of file alert_rule.h.
Referenced by config(), set_evaluation_interval(), set_for_duration(), set_repeat_interval(), and validate().
|
private |
Definition at line 313 of file alert_rule.h.
Referenced by is_enabled(), and set_enabled().
|
private |
Definition at line 307 of file alert_rule.h.
Referenced by create_alert(), group(), and set_group().
|
private |
Definition at line 310 of file alert_rule.h.
Referenced by add_label(), create_alert(), and labels().
|
private |
Definition at line 308 of file alert_rule.h.
Referenced by metric_name(), and set_metric_name().
|
private |
Definition at line 306 of file alert_rule.h.
Referenced by create_alert(), name(), and validate().
|
private |
Definition at line 309 of file alert_rule.h.
Referenced by create_alert(), set_severity(), and severity().
|
private |
Definition at line 314 of file alert_rule.h.
Referenced by set_trigger(), trigger(), and validate().