1.17. Set entity alert
Function set_alert() allows the user to set an alert on a specific entity.
When the alert is triggered, the listener callback on_alert_triggered will be called with the corresponding parameters.
In addition, if no entity matches the alert, the listener callback on_alert_timeout will be called periodically
If a valid script is passed as an advanced parameter, it will be executed when the alert is triggered.
StatisticsBackend::set_alert(
"NewDataAlert", // Alert name
domain_id, // Domain ID to monitor
"my_host", // Host name to monitor
"my_user", // User name to monitor
"my_topic", // Topic name to monitor
AlertKind::NEW_DATA_ALERT, // Kind of alert
0.0, // Threshold (Ignored for new data)
std::chrono::milliseconds(500), // Minimum time between two consecutive triggers (in ms)
std::chrono::milliseconds(10000), // Alert timeout (in ms)
"/some_path/script.sh");
To remove the alert, the user can call remove_alert() with the id of the alert to be removed.
StatisticsBackend::remove_alert(alert_id);