alerting
Alerting module.
- class spicerack.alerting.AlertingHosts(alertmanager_hosts: spicerack.alertmanager.AlertmanagerHosts, icinga_hosts: spicerack.icinga.IcingaHosts) None [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
, default:datetime.timedelta(seconds=14400)
) -- how long to downtime for.
- Return type:
- Returns:
The alertmanager downtime ID.
- Raises:
spicerack.alertmanager.AlertmanagerError -- if none of the
alertmanager_urls
API returned a success.spicerack.icinga.IcingaError -- if there is a problem downtiming the hosts on Icinga.
- downtimed(reason: spicerack.administrative.Reason, *, duration: datetime.timedelta = datetime.timedelta(seconds=14400), remove_on_error: bool = False) collections.abc.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
, default:datetime.timedelta(seconds=14400)
) -- the length of the downtime period.remove_on_error (
bool
, default:False
) -- 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.
- Return type: