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

Group of related alerts for batch notification. More...

#include <alert_types.h>

Collaboration diagram for kcenon::monitoring::alert_group:
Collaboration graph

Public Member Functions

 alert_group ()
 
 alert_group (std::string key)
 
void add_alert (alert a)
 Add an alert to the group.
 
size_t size () const
 Get count of alerts in the group.
 
bool empty () const
 Check if group is empty.
 
alert_severity max_severity () const
 Get highest severity in the group.
 

Public Attributes

std::string group_key
 Common grouping key.
 
std::vector< alertalerts
 Alerts in this group.
 
std::chrono::steady_clock::time_point created_at
 Group creation time.
 
std::chrono::steady_clock::time_point updated_at
 Last modification time.
 
alert_labels common_labels
 Labels shared by all alerts.
 

Detailed Description

Group of related alerts for batch notification.

Alerts with the same group key are combined into an alert group to reduce notification noise.

Examples
alert_notifiers_example.cpp.

Definition at line 322 of file alert_types.h.

Constructor & Destructor Documentation

◆ alert_group() [1/2]

kcenon::monitoring::alert_group::alert_group ( )
inline

Definition at line 329 of file alert_types.h.

330 : created_at(std::chrono::steady_clock::now())
std::chrono::steady_clock::time_point created_at
Group creation time.
std::chrono::steady_clock::time_point updated_at
Last modification time.

◆ alert_group() [2/2]

kcenon::monitoring::alert_group::alert_group ( std::string key)
inlineexplicit

Definition at line 333 of file alert_types.h.

334 : group_key(std::move(key))
335 , created_at(std::chrono::steady_clock::now())
std::string group_key
Common grouping key.

Member Function Documentation

◆ add_alert()

void kcenon::monitoring::alert_group::add_alert ( alert a)
inline

Add an alert to the group.

Parameters
aAlert to add

Definition at line 342 of file alert_types.h.

342 {
343 alerts.push_back(std::move(a));
344 updated_at = std::chrono::steady_clock::now();
345 }
std::vector< alert > alerts
Alerts in this group.

References alerts, and updated_at.

Referenced by kcenon::monitoring::alert_aggregator::add_alert(), kcenon::monitoring::buffered_notifier::flush_internal(), and main().

Here is the caller graph for this function:

◆ empty()

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

Check if group is empty.

Returns
True if no alerts in group

Definition at line 359 of file alert_types.h.

359 {
360 return alerts.empty();
361 }

References alerts.

Referenced by TEST_F().

Here is the caller graph for this function:

◆ max_severity()

alert_severity kcenon::monitoring::alert_group::max_severity ( ) const
inline

Get highest severity in the group.

Returns
Maximum severity level

Definition at line 367 of file alert_types.h.

367 {
369 for (const auto& a : alerts) {
370 if (static_cast<uint8_t>(a.severity) > static_cast<uint8_t>(max_sev)) {
371 max_sev = a.severity;
372 }
373 }
374 return max_sev;
375 }
alert_severity
Severity levels for alerts.
Definition alert_types.h:35
@ info
Informational, no action required.

References alerts, and kcenon::monitoring::info.

Referenced by kcenon::monitoring::json_alert_formatter::format_group(), kcenon::monitoring::text_alert_formatter::format_group(), and main().

Here is the caller graph for this function:

◆ size()

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

Get count of alerts in the group.

Returns
Number of alerts

Definition at line 351 of file alert_types.h.

351 {
352 return alerts.size();
353 }

References alerts.

Referenced by kcenon::monitoring::json_alert_formatter::format_group(), kcenon::monitoring::text_alert_formatter::format_group(), main(), kcenon::monitoring::console_color_notifier::notify_group(), and TEST_F().

Here is the caller graph for this function:

Member Data Documentation

◆ alerts

◆ common_labels

alert_labels kcenon::monitoring::alert_group::common_labels

Labels shared by all alerts.

Definition at line 327 of file alert_types.h.

Referenced by kcenon::monitoring::alert_aggregator::add_alert(), and main().

◆ created_at

std::chrono::steady_clock::time_point kcenon::monitoring::alert_group::created_at

Group creation time.

Definition at line 325 of file alert_types.h.

◆ group_key

std::string kcenon::monitoring::alert_group::group_key

◆ updated_at

std::chrono::steady_clock::time_point kcenon::monitoring::alert_group::updated_at

Last modification time.

Definition at line 326 of file alert_types.h.

Referenced by add_alert().


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