alerting

Alerting module.

class spicerack.alerting.AlertingHosts(alertmanager_hosts: AlertmanagerHosts, icinga_hosts: IcingaHosts)[source]

Bases: object

Operate on Alertmanager and Icinga via their APIs.

Initialize the instance.

Parameters:
downtime(reason: Reason, *, duration: timedelta = datetime.timedelta(seconds=14400)) str[source]

Issue a new downtime.

Parameters:
Returns:

the downtime ID.

Return type:

str

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: Reason, *, duration: 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:
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.

remove_downtime(downtime_id: str) None[source]

Remove a downtime.

Parameters:

downtime_id (str) -- the downtime ID to remove.