|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Groups and deduplicates alerts. More...
#include <alert_pipeline.h>

Public Member Functions | |
| alert_aggregator (const alert_aggregator_config &config) | |
| Construct with configuration. | |
| std::string | add_alert (const alert &a) |
| Add an alert for aggregation. | |
| std::vector< alert_group > | get_ready_groups () |
| Get groups ready for notification. | |
| void | mark_sent (const std::string &group_key) |
| Mark a group as sent. | |
| void | cleanup () |
| Remove resolved alerts and clean up old groups. | |
| size_t | group_count () const |
| Get current group count. | |
| size_t | total_alert_count () const |
| Get total alert count across all groups. | |
Private Member Functions | |
| std::string | compute_group_key (const alert &a) const |
| alert_labels | extract_common_labels (const alert &a) const |
Private Attributes | |
| alert_aggregator_config | config_ |
| std::mutex | mutex_ |
| std::unordered_map< std::string, alert_group > | groups_ |
| std::unordered_map< std::string, std::chrono::steady_clock::time_point > | first_seen_ |
| std::unordered_map< std::string, std::chrono::steady_clock::time_point > | last_sent_ |
Groups and deduplicates alerts.
The aggregator collects alerts over time and groups them based on configured labels. This reduces notification noise by batching related alerts together.
Definition at line 79 of file alert_pipeline.h.
|
inlineexplicit |
Construct with configuration.
Definition at line 84 of file alert_pipeline.h.
|
inline |
Add an alert for aggregation.
| a | Alert to aggregate |
Definition at line 92 of file alert_pipeline.h.
References kcenon::monitoring::alert_group::add_alert(), kcenon::monitoring::alert_group::common_labels, compute_group_key(), extract_common_labels(), kcenon::monitoring::alert::fingerprint(), first_seen_, groups_, and mutex_.
Referenced by main().


|
inline |
Remove resolved alerts and clean up old groups.
Definition at line 170 of file alert_pipeline.h.
References config_, first_seen_, groups_, last_sent_, mutex_, kcenon::monitoring::alert_aggregator_config::resolve_timeout, and kcenon::monitoring::resolved.
Referenced by main().

|
inlineprivate |
Definition at line 223 of file alert_pipeline.h.
References config_, kcenon::monitoring::alert_labels::get(), kcenon::monitoring::alert_aggregator_config::group_by_labels, kcenon::monitoring::alert::labels, and kcenon::monitoring::alert::rule_name.
Referenced by add_alert().


|
inlineprivate |
Definition at line 235 of file alert_pipeline.h.
References config_, kcenon::monitoring::alert_labels::get(), kcenon::monitoring::alert_aggregator_config::group_by_labels, kcenon::monitoring::alert::labels, and kcenon::monitoring::alert_labels::set().
Referenced by add_alert().


|
inline |
Get groups ready for notification.
Definition at line 127 of file alert_pipeline.h.
References config_, first_seen_, kcenon::monitoring::alert_aggregator_config::group_interval, kcenon::monitoring::alert_aggregator_config::group_wait, groups_, last_sent_, and mutex_.
Referenced by main().

|
inline |
Get current group count.
Definition at line 205 of file alert_pipeline.h.
References groups_, and mutex_.
Referenced by main().

|
inline |
Mark a group as sent.
| group_key | Group key to mark |
Definition at line 162 of file alert_pipeline.h.
References last_sent_, and mutex_.
Referenced by main().

|
inline |
Get total alert count across all groups.
Definition at line 213 of file alert_pipeline.h.
References groups_, and mutex_.
Referenced by main().

|
private |
Definition at line 246 of file alert_pipeline.h.
Referenced by cleanup(), compute_group_key(), extract_common_labels(), and get_ready_groups().
|
private |
Definition at line 250 of file alert_pipeline.h.
Referenced by add_alert(), cleanup(), and get_ready_groups().
|
private |
Definition at line 249 of file alert_pipeline.h.
Referenced by add_alert(), cleanup(), get_ready_groups(), group_count(), and total_alert_count().
|
private |
Definition at line 251 of file alert_pipeline.h.
Referenced by cleanup(), get_ready_groups(), and mark_sent().
|
mutableprivate |
Definition at line 247 of file alert_pipeline.h.
Referenced by add_alert(), cleanup(), get_ready_groups(), group_count(), mark_sent(), and total_alert_count().