PagerDuty Alert Task
Learn how to send PagerDuty alerts from Synnax when statuses change.
The PagerDuty integration watches status keys and opens or resolves PagerDuty incidents when they change. Error, warning, and info variants send an event with the matching severity. Success resolves the open incident. Events are deduplicated by status key, so repeated changes update the existing incident.
The integration runs on the Synnax Core, not on the Driver, so the Core must reach
events.pagerduty.com over HTTPS.
For the task lifecycle, see Task Basics.
Prerequisites
- A PagerDuty account.
- A PagerDuty service with an Events API v2 integration. In PagerDuty, open
Services->Service Directory, select the service, thenIntegrations->Add Integration->Events API v2. - The 32-character integration key (routing key) from that integration.
Severity Mapping
Supported Operating Systems
Task Configuration Reference
Alert Configuration Reference
Each alert maps a Synnax status key to a PagerDuty event. The task needs at least one alert that is not disabled.
How-To
Console
Python
Create and run an alert task
import synnax as sy
client = sy.Synnax()
# Create a status to watch
STATUS_KEY = "example-pagerduty-status"
client.statuses.set(
sy.Status(
key=STATUS_KEY,
name="Engine 1",
variant="success",
message="Engine 1 is healthy",
)
)
# Create the PagerDuty alert task
alert_task = sy.pagerduty.AlertTask(
name="Example PagerDuty Alert",
routing_key="<your-32-character-integration-key>",
auto_start=False,
alerts=[
sy.pagerduty.Alert(
status=STATUS_KEY,
errors_critical=True,
component="engine-1",
group="engines",
class_="engine-failure",
),
],
)
# Configure the task with Synnax
client.tasks.configure(alert_task)
# Start the task - it will watch for status changes
with alert_task.run():
# Trigger a PagerDuty incident by setting status to error
client.statuses.set(
sy.Status(
key=STATUS_KEY,
name="Engine 1",
variant="error",
message="Engine 1 is down",
description="Connection to database lost",
)
)
sy.sleep(5)
# Resolve by setting status back to success
client.statuses.set(
sy.Status(
key=STATUS_KEY,
name="Engine 1",
variant="success",
message="Engine 1 recovered",
)
)
sy.sleep(3)
# Task automatically stops when exiting the context manager