# Route p1 alerts to PagerDuty

This example shows how to send P1 alerts to a PagerDuty service using Notification Center.\
You configure a PagerDuty connector, create a preset, define a router and routing rule, and label alerts for correct delivery.

## Workflow overview

1. Create a PagerDuty connector: connects Coralogix to a PagerDuty service
1. Create a preset: defines the PagerDuty event payload
1. Create a router and routing rule: sends only P1 alerts to PagerDuty
1. Label alerts: ensures alerts match the router

## Create a PagerDuty connector

1. Go to **Integrations**, then **Notification Center**, then **Connectors**.

1. Select **+ New connector**.

1. Choose **PagerDuty** as the destination type.

1. In **Details**, enter a name and optional description.\
   Example: `PagerDuty-Prod`.

1. In **Configuration**:

   - **Service key:** Enter your PagerDuty integration key.\
     See PagerDuty guide for instructions.

1. (Optional) Select **Advanced**, then **Dynamic fields**, define a dynamic service key to route alerts to different PagerDuty services.

   **Example:**

   ```text
   {% if alert.highestPriority == "P1" %}
   930aaaaaaaaaaaaaaaaaaaaaaaaaa0d1
   {% elif alert.highestPriority == "P2" %}
   930bbbbbbbbbbbbbbbbbbbbbbbbbb0d1
   {% else %}
   930xxxxxxxxxxxxxxxxxxxxxxxxxx0d1
   {% endif %}
   ```

1. Select **Send test notification**.

1. Select **Create connector**.

## Create a preset (optional)

If you do not need a custom message format, skip this section and use the system preset.

1. Go to **Integrations**, then **Notification Center**, then **Presets**.

1. Open the **Alerts** tab and select **PagerDuty**.

1. Select **+ New alert preset**.

1. Customize the **Triggered** template fields:

   | Field              | Example template                           |
   | ------------------ | ------------------------------------------ |
   | **Summary**        | `{{ alertDef.name }} - Triggered`          |
   | **Severity**       | `"critical"`                               |
   | **Source**         | `{{ _context.system.name }}`               |
   | **Timestamp**      | `{{ alert.timestamp }}`                    |
   | **Custom details** | \`{ "description": {{ alertDef.description |

1. Use the **Preview** panel to review output.

1. (Optional) Use **Send test notification** to validate with your PagerDuty connector.

1. Select **Create preset**.

## Create a router and routing rule

1. Go to **Integrations**, then **Notification Center**, then **Routers**.

1. Select **+ New router**.

1. In **Details**, enter a router name such as `Critical Alerts`.

1. In **Routing labels**, add labels that this router matches:

   ```text
   group:sre
   environment:prod
   ```

   5. Add a routing rule:

1. **Condition**

   ```text
   alert.highestPriority == "P1"
   ```

1. **Destination**

   - Connector: `PagerDuty-Prod`
   - Preset: `PagerDuty Critical Alert`

1. (Optional) In **Fallback**, select a connector to receive unmatched alerts.

1. Select **Create router**.

## Label alerts

1. Go to **Alerts**, then **Create alert**.

1. In **Labels**, add routing labels matching your router:

   ```text
   routing.team:sre
   routing.environment:prod
   ```

1. Set the alert **priority** to `P1`.

1. Save the alert.

When triggered, the alert is routed through the **Critical Alerts** router and sent to PagerDuty.

## Example result

A triggered alert produces a PagerDuty event like:

**Summary:** `CPU Usage High - Triggered`

**Severity:** `critical`

**Source:** `prod-cluster-01`

**Custom details:** `CPU utilization exceeded 95% on host server-1.`

## Next steps

Review the permissions required for managing Notification Center in [Permissions](https://coralogix.com/docs/user-guides/notification-center/permissions/index.md).
