> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flashcat.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# PagerDuty Integration

> Push alert events to Flashduty through PagerDuty protocol for automated alert noise reduction

Synchronize via webhook

Flashduty implements PagerDuty Events API with full input and response compatibility. This allows you to push alert events to Flashduty using the PagerDuty protocol for automated alert noise reduction.

Similarly, for alert systems that already support pushing events to PagerDuty (such as ElastAlert), you only need to modify the destination push URL to utilize the PagerDuty protocol for pushing events to Flashduty.

<div class="hide">
  ## In Flashduty

  ***

  You can obtain an integration push URL through either of these two methods:

  ### Using Private Integration

  Choose this simpler option when you don't need to route alert events to different channels.

  <details>
    <summary>Expand</summary>

    1. Go to the Flashduty console, select **channel**, and enter a specific channel's details page
    2. Select the **Integrations** tab, click **Add Integration** to enter the integration page
    3. Choose **PagerDuty** integration and click **Save** to generate a card
    4. Click the generated card to view the **push URL**, copy it for later use, and you're done
  </details>

  ### Using Shared Integration

  Choose this option when you need to route alerts to different channels based on the alert event's payload information.

  <details>
    <summary>Expand</summary>

    1. Go to the Flashduty console, select **Integration Center=>Alert Events** to enter the integration selection page
    2. Select **PagerDuty** integration:
       * **Integration Name**: Define a name for this integration
    3. Configure the default route and select the corresponding channel (after the integration is created, you can go to `Route` to configure more routing rules)
    4. Click **Save** and copy the newly generated **push URL** for later use
    5. Done
  </details>
</div>

## In PagerDuty

***

### Request URL

```
{api_host}/event/push/alert/pagerduty
```

This URL supports both PagerDuty V1 and V2 Events API. **You must modify the PagerDuty URL to this address.**

### PagerDuty V2 Events

<div class="md-block">
  #### Reference Documentation:

  [PagerDuty V2 Events](https://developer.pagerduty.com/api-reference/368ae3d938c9e-send-an-event-to-pager-duty)

  #### Authentication Methods:

  Choose one of these two methods:

  * Method 1: Include integration\_key parameter in QueryString
  * Method 2: Pass integration\_key as routing\_key parameter in Payload
</div>

### PagerDuty V1 Events

<div class="md-block">
  #### Reference Documentation:

  [PagerDuty V1 Events](https://developer.pagerduty.com/api-reference/f0037990796c8-send-an-event-to-pager-duty)

  #### Authentication Methods:

  Choose one of these two methods:

  * Method 1: Include integration\_key parameter in QueryString
  * Method 2: Pass integration\_key as service\_key parameter in Payload
</div>

### Configuration Example

Using [ElastAlert2](https://github.com/jertel/elastalert2) as an example:

<div class="md-block">
  1. Step 1: Obtain Push URL

  Enter integration name on the current page and save. Reopen integration details and copy the push URL, such as:

  ```
  {api_host}/event/push/alert/pagerduty?integration_key=xxx
  ```

  2. Step 2: Modify Push URL

  Modify the corresponding source code of your deployed ElastAlert instance, [view diff](https://github.com/jertel/elastalert2/commit/e815a62a6b1eecef6e1fef13afd99d905b67fc34):

  <img alt="drawing" width="600" src="https://download.flashcat.cloud/pagerduty-replace-endpoint.png" />

  3. Step 3: Report Alert Events

  Follow the [ElastAlert PagerDuty push configuration documentation](https://elastalert2.readthedocs.io/en/latest/ruletypes.html#pagerduty) steps to configure alerts:

  ```
  name: "b"
  type: "frequency"
  index: "pgy_audit*"
  is_enabled: true
  num_events: 1
  realert:
    minutes: 1
  terms_size: 50
  scan_entire_timeframe: true
  timeframe:
    minutes: 60
  timestamp_field: "created_at"
  timestamp_type: "unix_ms"
  use_strftime_index: false
  alert_subject: "Test {0} 123 aa☃ {1}"
  alert_subject_args:
    - "account_id"
    - "operation"
  alert_text: "Test {0}  123 bb☃ {1}"
  alert_text_args:
    - "request_id"
    - "operation_name"
  filter:
    - query:
        query_string:
          query: "created_at:*"

  # ------- Flashduty ----------------
  alert: pagerduty
  pagerduty_service_key: xxx
  pagerduty_client_name: wahaha
  pagerduty_api_version: v2
  pagerduty_v2_payload_class: ping failure
  pagerduty_v2_payload_component: mysql
  pagerduty_v2_payload_group: app-stack
  pagerduty_v2_payload_severity: error
  pagerduty_v2_payload_source: mysql.host.name
  # ------- Flashduty ----------------
  ```

  4. Step 4: Restart ElastAlert and wait for alerts to trigger
</div>
