airflow.providers.pagerduty.hooks.pagerduty_events
¶
Hook for sending or receiving data from PagerDuty as well as creating PagerDuty incidents.
Module Contents¶
Classes¶
This class can be used to interact with the Pagerduty Events API. |
- class airflow.providers.pagerduty.hooks.pagerduty_events.PagerdutyEventsHook(integration_key=None, pagerduty_events_conn_id=None)[source]¶
Bases:
airflow.hooks.base.BaseHook
This class can be used to interact with the Pagerduty Events API.
- It takes both an Events API token and a PagerDuty connection with the Events API token
(i.e. Integration key) as the password/Pagerduty API token. If both supplied, the token will be used.
- Parameters
- send_event(summary, severity, source='airflow', action='trigger', 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.
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
- static prepare_event_data(summary, severity, source, custom_details, component, group, class_type, action, dedup_key, images, links, action_key_name='action')[source]¶
Prepare event data for send_event / post(‘/v2/enqueue’) method.
- create_change_event(summary, source='airflow', custom_details=None, timestamp=None, links=None)[source]¶
Create change event for service integration.
- Parameters
summary (str) – Summary for the event
source (str) – Specific human-readable unique identifier, such as a hostname, for the system having the problem.
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.
timestamp (datetime.datetime | None) – The time at which the emitting tool detected or generated the event.
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 Change Events API v2 response.
- Return type