alerting¶
Alerting module.
- class spicerack.alerting.AlertingHosts(alertmanager_hosts: spicerack.alertmanager.AlertmanagerHosts, icinga_hosts: spicerack.icinga.IcingaHosts)[source]¶
Bases:
object
Operate on Alertmanager and Icinga via their APIs.
Initialize the instance.
- Parameters
alertmanager_hosts (spicerack.alertmanager.AlertmanagerHosts) -- the Alertmanager hosts to talk to.
icinga_hosts (spicerack.icinga.IcingaHosts) -- the Icinga hosts to talk to.
- downtime(reason: spicerack.administrative.Reason, *, duration: datetime.timedelta = datetime.timedelta(seconds=14400)) str [source]¶
Issue a new downtime.
- Parameters
reason (spicerack.administrative.Reason) -- the downtime reason.
duration (datetime.timedelta) -- how long to downtime for.
- Returns
the downtime ID.
- Return type
- Raises
AlertmanagerError -- if none of the alertmanager_urls API returned a success.
IcingaError -- if there is a problem downtiming the hosts in Icinga.
- downtimed(reason: spicerack.administrative.Reason, *, duration: datetime.timedelta = datetime.timedelta(seconds=14400), remove_on_error: bool = False) Iterator[None] [source]¶
Context manager to perform actions while the hosts are downtimed on Alertmanager and Icinga.
- Parameters
reason (spicerack.administrative.Reason) -- the reason to set for the downtime.
duration (datetime.timedelta, optional) -- the length of the downtime period.
remove_on_error -- should the downtime be removed even if an exception was raised.
- Yields
None -- it just yields control to the caller once Alertmanager and Icinga have received the downtime and deletes the downtime once getting back the control.