airflow.providers.pagerduty.hooks.pagerduty_events

Hook for sending or receiving data from PagerDuty as well as creating PagerDuty incidents.

Module Contents

Classes

PagerdutyEventsHook

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
  • integration_key (Optional[str]) -- PagerDuty Events API token

  • pagerduty_conn_id -- connection that has PagerDuty integration key in the Pagerduty API token field

conn_name_attr = pagerduty_events_conn_id[source]
default_conn_name = pagerduty_events_default[source]
conn_type = pagerduty_events[source]
hook_name = Pagerduty Events[source]
static get_ui_field_behaviour()[source]

Returns custom field behaviour

create_event(self, 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 (Optional[str]) -- A string which identifies the alert triggered for the given event. Required for the actions acknowledge and resolve.

  • custom_details (Optional[Any]) -- 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 (Optional[str]) -- A cluster or grouping of sources. For example, sources “prod-datapipe-02” and “prod-datapipe-03” might both be part of “prod-datapipe”

  • component (Optional[str]) -- The part or component of the affected system that is broken.

  • class_type (Optional[str]) -- The class/type of the event.

  • images (Optional[List[Any]]) -- 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 (Optional[List[Any]]) -- 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

dict

Was this entry helpful?