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:
downtime(reason: spicerack.administrative.Reason, *, duration: datetime.timedelta = datetime.timedelta(seconds=14400)) str[source]

Issue a new downtime.

Parameters:
Return type:

str

Returns:

The alertmanager downtime ID.

Raises:
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:

collections.abc.Iterator[None]

remove_downtime(downtime_id: str) None[source]

Remove a downtime.

Parameters:

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

Return type:

None