Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::alert_rule_group Class Reference

A group of related alert rules. More...

#include <alert_rule.h>

Collaboration diagram for kcenon::monitoring::alert_rule_group:
Collaboration graph

Public Member Functions

 alert_rule_group (std::string name)
 Construct a rule group.
 
const std::string & name () const
 Get group name.
 
void add_rule (std::shared_ptr< alert_rule > rule)
 Add a rule to the group.
 
const std::vector< std::shared_ptr< alert_rule > > & rules () const
 Get all rules in the group.
 
size_t size () const
 Get number of rules.
 
bool empty () const
 Check if group is empty.
 
void set_common_interval (std::chrono::milliseconds interval)
 Set common evaluation interval for all rules.
 
std::optional< std::chrono::milliseconds > common_interval () const
 Get common evaluation interval.
 

Private Attributes

std::string name_
 
std::vector< std::shared_ptr< alert_rule > > rules_
 
std::optional< std::chrono::milliseconds > common_interval_
 

Detailed Description

A group of related alert rules.

Rule groups allow organizing rules and applying common settings to multiple rules.

Definition at line 356 of file alert_rule.h.

Constructor & Destructor Documentation

◆ alert_rule_group()

kcenon::monitoring::alert_rule_group::alert_rule_group ( std::string name)
inlineexplicit

Construct a rule group.

Parameters
nameGroup name
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 362 of file alert_rule.h.

363 : name_(std::move(name)) {}
const std::string & name() const
Get group name.
Definition alert_rule.h:369

Member Function Documentation

◆ add_rule()

void kcenon::monitoring::alert_rule_group::add_rule ( std::shared_ptr< alert_rule > rule)
inline

Add a rule to the group.

Parameters
ruleRule to add
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 375 of file alert_rule.h.

375 {
376 if (rule) {
377 rule->set_group(name_);
378 rules_.push_back(std::move(rule));
379 }
380 }
std::vector< std::shared_ptr< alert_rule > > rules_
Definition alert_rule.h:423

References name_, and rules_.

Referenced by TEST(), TEST(), and TEST().

Here is the caller graph for this function:

◆ common_interval()

std::optional< std::chrono::milliseconds > kcenon::monitoring::alert_rule_group::common_interval ( ) const
inline

Get common evaluation interval.

Returns
Evaluation interval if set
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 417 of file alert_rule.h.

417 {
418 return common_interval_;
419 }
std::optional< std::chrono::milliseconds > common_interval_
Definition alert_rule.h:424

References common_interval_.

Referenced by TEST(), and TEST().

Here is the caller graph for this function:

◆ empty()

bool kcenon::monitoring::alert_rule_group::empty ( ) const
inline

Check if group is empty.

Returns
True if no rules
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 400 of file alert_rule.h.

400{ return rules_.empty(); }

References rules_.

Referenced by TEST(), TEST(), and TEST().

Here is the caller graph for this function:

◆ name()

const std::string & kcenon::monitoring::alert_rule_group::name ( ) const
inline

Get group name.

Returns
Group name
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 369 of file alert_rule.h.

369{ return name_; }

References name_.

Referenced by TEST().

Here is the caller graph for this function:

◆ rules()

const std::vector< std::shared_ptr< alert_rule > > & kcenon::monitoring::alert_rule_group::rules ( ) const
inline

Get all rules in the group.

Returns
Vector of rules
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 386 of file alert_rule.h.

386 {
387 return rules_;
388 }

References rules_.

◆ set_common_interval()

void kcenon::monitoring::alert_rule_group::set_common_interval ( std::chrono::milliseconds interval)
inline

Set common evaluation interval for all rules.

Parameters
intervalEvaluation interval
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 406 of file alert_rule.h.

406 {
407 common_interval_ = interval;
408 for (auto& rule : rules_) {
409 rule->set_evaluation_interval(interval);
410 }
411 }

References common_interval_, and rules_.

Referenced by TEST().

Here is the caller graph for this function:

◆ size()

size_t kcenon::monitoring::alert_rule_group::size ( ) const
inline

Get number of rules.

Returns
Rule count
Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_rule.h.

Definition at line 394 of file alert_rule.h.

394{ return rules_.size(); }

References rules_.

Referenced by TEST(), and TEST().

Here is the caller graph for this function:

Member Data Documentation

◆ common_interval_

std::optional<std::chrono::milliseconds> kcenon::monitoring::alert_rule_group::common_interval_
private

◆ name_

std::string kcenon::monitoring::alert_rule_group::name_
private

◆ rules_

std::vector<std::shared_ptr<alert_rule> > kcenon::monitoring::alert_rule_group::rules_
private

The documentation for this class was generated from the following file: