|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Sends alerts to a webhook endpoint. More...
#include <alert_notifiers.h>


Public Types | |
| using | http_sender_func |
Public Member Functions | |
| webhook_notifier (const webhook_config &config, std::shared_ptr< alert_formatter > formatter=nullptr) | |
| Construct webhook notifier. | |
| std::string | name () const override |
| Get notifier name. | |
| common::VoidResult | notify (const alert &a) override |
| Send a notification for an alert. | |
| common::VoidResult | notify_group (const alert_group &group) override |
| Send a notification for an alert group. | |
| bool | is_ready () const override |
| Check if notifier is ready. | |
| void | set_http_sender (http_sender_func sender) |
| Set HTTP sender function for actual HTTP calls. | |
| const webhook_config & | config () const |
| Get configuration. | |
Public Member Functions inherited from kcenon::monitoring::alert_notifier | |
| virtual | ~alert_notifier ()=default |
Private Member Functions | |
| common::VoidResult | send_with_retry (const std::string &payload) |
Private Attributes | |
| webhook_config | config_ |
| std::shared_ptr< alert_formatter > | formatter_ |
| http_sender_func | http_sender_ |
Sends alerts to a webhook endpoint.
Note: Actual HTTP implementation requires network_system integration or an external HTTP client. This implementation provides the interface and can be extended with actual HTTP support.
Definition at line 197 of file alert_notifiers.h.
Definition at line 199 of file alert_notifiers.h.
|
inlineexplicit |
Construct webhook notifier.
| config | Webhook configuration |
| formatter | Alert formatter (default: JSON) |
Definition at line 211 of file alert_notifiers.h.
|
inline |
|
inlineoverridevirtual |
Check if notifier is ready.
Implements kcenon::monitoring::alert_notifier.
Definition at line 234 of file alert_notifiers.h.
References config_, http_sender_, and kcenon::monitoring::webhook_config::validate().

|
inlineoverridevirtual |
Get notifier name.
Implements kcenon::monitoring::alert_notifier.
Definition at line 216 of file alert_notifiers.h.
References config_, and kcenon::monitoring::webhook_config::url.
|
inlineoverridevirtual |
Send a notification for an alert.
| a | Alert to notify about |
Implements kcenon::monitoring::alert_notifier.
Definition at line 220 of file alert_notifiers.h.
References config_, formatter_, kcenon::monitoring::resolved, kcenon::monitoring::webhook_config::send_resolved, send_with_retry(), and kcenon::monitoring::alert::state.

|
inlineoverridevirtual |
Send a notification for an alert group.
| group | Alert group to notify about |
Implements kcenon::monitoring::alert_notifier.
Definition at line 229 of file alert_notifiers.h.
References formatter_, and send_with_retry().

|
inlineprivate |
Definition at line 263 of file alert_notifiers.h.
References config_, kcenon::monitoring::webhook_config::content_type, kcenon::monitoring::webhook_config::headers, http_sender_, kcenon::monitoring::webhook_config::max_retries, kcenon::monitoring::webhook_config::method, kcenon::monitoring::operation_failed, kcenon::monitoring::retry_attempts_exhausted, kcenon::monitoring::webhook_config::retry_delay, and kcenon::monitoring::webhook_config::url.
Referenced by notify(), and notify_group().

|
inline |
Set HTTP sender function for actual HTTP calls.
| sender | Function to send HTTP requests |
This allows injecting a real HTTP implementation:
Definition at line 253 of file alert_notifiers.h.
References http_sender_.
|
private |
Definition at line 287 of file alert_notifiers.h.
Referenced by config(), is_ready(), name(), notify(), and send_with_retry().
|
private |
Definition at line 288 of file alert_notifiers.h.
Referenced by notify(), and notify_group().
|
private |
Definition at line 289 of file alert_notifiers.h.
Referenced by is_ready(), send_with_retry(), and set_http_sender().