awslimitchecker.alerts.pagerdutyv1 module

class awslimitchecker.alerts.pagerdutyv1.PagerDutyV1(region_name, account_alias=None, critical_service_key=None, warning_service_key=None, incident_key=None)[source]

Bases: awslimitchecker.alerts.base.AlertProvider

Initialize PagerDutyV1 alert provider.

Parameters:
  • region_name (str) – the name of the region we’re connected to
  • account_alias – Optional; an alias for the account that awslimitchecker is currently running against, to use in the default incident_key and description.
  • critical_service_key (str) – Required; the PagerDuty Integration Key for sending Critical events. Can also be specified via the PAGERDUTY_SERVICE_KEY_CRIT environment variable.
  • warning_service_key (str) – Required; the PagerDuty Integration Key for sending Warning events. Can also be specified via the PAGERDUTY_SERVICE_KEY_WARN environment variable. If omitted, alerts will not be sent for warnings.
  • incident_key (str) – Optional; the PagerDuty incident/routing key to use, for de-duplication and resolving alerts. This string will have any occurrences of {account_alias} replaced with the account alias (or an empty string, if not specified) and any occurrences of {region_name} replaced with the current region name. If not specified, this will default to awslimitchecker-{account_alias}-{region_name}.
__init__(region_name, account_alias=None, critical_service_key=None, warning_service_key=None, incident_key=None)[source]

Initialize PagerDutyV1 alert provider.

Parameters:
  • region_name (str) – the name of the region we’re connected to
  • account_alias – Optional; an alias for the account that awslimitchecker is currently running against, to use in the default incident_key and description.
  • critical_service_key (str) – Required; the PagerDuty Integration Key for sending Critical events. Can also be specified via the PAGERDUTY_SERVICE_KEY_CRIT environment variable.
  • warning_service_key (str) – Required; the PagerDuty Integration Key for sending Warning events. Can also be specified via the PAGERDUTY_SERVICE_KEY_WARN environment variable. If omitted, alerts will not be sent for warnings.
  • incident_key (str) – Optional; the PagerDuty incident/routing key to use, for de-duplication and resolving alerts. This string will have any occurrences of {account_alias} replaced with the account alias (or an empty string, if not specified) and any occurrences of {region_name} replaced with the current region name. If not specified, this will default to awslimitchecker-{account_alias}-{region_name}.
__module__ = 'awslimitchecker.alerts.pagerdutyv1'
_event_dict()[source]

Return a skeleton dictionary for the PagerDuty V1 Event.

Returns:skeleton of Event
Return type:dict
_problems_dict(problems)[source]

Make a dict of problems suitable for inclusion in Event details.

Parameters:problems (dict) – dict of service name to nested dict of limit name to limit, same format as the return value of check_thresholds(). None if exc is specified.
Returns:problems summary suitable for Event details
Return type:dict
_send_event(service_key, payload)[source]

Send an event to PagerDuty.

Parameters:
  • service_key (str) – service key to send to
  • payload (dict) – data to send with event
on_critical(problems, problem_str, exc=None, duration=None)[source]

Method called when the run encountered errors, or at least one critical threshold was met or crossed.

Parameters:
  • problems (dict or None) – dict of service name to nested dict of limit name to limit, same format as the return value of check_thresholds(). None if exc is specified.
  • problem_str (str or None) – String representation of problems, as displayed in awslimitchecker command line output. None if exc is specified.
  • exc (Exception) – Exception object that was raised during the run (optional)
  • duration (float) – duration of the run
on_success(duration=None)[source]

Method called when no thresholds were breached, and run completed successfully. Should resolve any open incidents (if the service supports that functionality) or else simply return.

Parameters:duration (float) – duration of the usage/threshold checking run
on_warning(problems, problem_str, duration=None)[source]

Method called when one or more warning thresholds were crossed, but no criticals and the run did not encounter any errors.

Parameters:
  • problems (dict or None) – dict of service name to nested dict of limit name to limit, same format as the return value of check_thresholds().
  • problem_str (str or None) – String representation of problems, as displayed in awslimitchecker command line output.
  • duration (float) – duration of the run
pd_url = 'https://events.pagerduty.com/generic/2010-04-15/create_event.json'