airflow.providers.pagerduty.hooks.pagerduty
¶
Hook for sending or receiving data from PagerDuty as well as creating PagerDuty incidents.
Module Contents¶
Classes¶
The PagerdutyHook can be used to interact with both the PagerDuty API and the PagerDuty Events API. |
- class airflow.providers.pagerduty.hooks.pagerduty.PagerdutyHook(token=None, pagerduty_conn_id=None)[source]¶
Bases:
airflow.hooks.base.BaseHook
The PagerdutyHook can be used to interact with both the PagerDuty API and the PagerDuty Events API.
Takes both PagerDuty API token directly and connection that has PagerDuty API token. If both supplied, PagerDuty API token will be used. In these cases, the PagerDuty API token refers to an account token: https://support.pagerduty.com/docs/generating-api-keys#generating-a-general-access-rest-api-key https://support.pagerduty.com/docs/generating-api-keys#generating-a-personal-rest-api-key
In order to send events (with the Pagerduty Events API), you will also need to specify the routing_key (or Integration key) in the
extra
field- Parameters
- classmethod get_connection_form_widgets()[source]¶
Return connection widgets to add to connection form.
- get_session()[source]¶
Return pdpyras.APISession for use with sending or receiving data through the PagerDuty REST API.
The pdpyras library supplies a class pdpyras.APISession extending requests.Session from the Requests HTTP library.
Documentation on how to use the APISession class can be found at: https://pagerduty.github.io/pdpyras/#data-access-abstraction
- create_event(summary, severity, source='airflow', action='trigger', routing_key=None, dedup_key=None, custom_details=None, group=None, component=None, class_type=None, images=None, links=None)[source]¶
Create event for service integration.
- Parameters
summary (str) – Summary for the event
severity (str) – Severity for the event, needs to be one of: info, warning, error, critical
source (str) – Specific human-readable unique identifier, such as a hostname, for the system having the problem.
action (str) – Event action, needs to be one of: trigger, acknowledge, resolve. Default to trigger if not specified.
routing_key (str | None) – Integration key. If not specified, will try to read from connection’s extra json blob.
dedup_key (str | None) – A string which identifies the alert triggered for the given event. Required for the actions acknowledge and resolve.
custom_details (Any | None) – Free-form details from the event. Can be a dictionary or a string. If a dictionary is passed it will show up in PagerDuty as a table.
group (str | None) – A cluster or grouping of sources. For example, sources “prod-datapipe-02” and “prod-datapipe-03” might both be part of “prod-datapipe”
component (str | None) – The part or component of the affected system that is broken.
class_type (str | None) – The class/type of the event.
images (list[Any] | None) – List of images to include. Each dictionary in the list accepts the following keys: src: The source (URL) of the image being attached to the incident. This image must be served via HTTPS. href: [Optional] URL to make the image a clickable link. alt: [Optional] Alternative text for the image.
links (list[Any] | None) – List of links to include. Each dictionary in the list accepts the following keys: href: URL of the link to be attached. text: [Optional] Plain text that describes the purpose of the link, and can be used as the link’s text.
- Returns
PagerDuty Events API v2 response.
- Return type