# OpsGenie

{% hint style="info" %}
This capability is only available to BYOC deployments. Check out our [pricing page](https://www.groundcover.com/pricing) for more information about subscription plans and the available deployment modes.
{% endhint %}

### Generate Opsgenie API Key

1. In Opsgenie, Go to **Settings → Integrations**.
2. Run a search and select “API”.
3. On the next screen, enter a name for the integration. (We will use it later when adding the integration to groundcover)
4. *Optional*: Select a team in **Assignee team** if you want a specific team to receive alerts from the integration.
5. Select **Continue**.\
   The integration is saved at this point.
6. Select **Turn on integration**.
   1. If you're using Opsgenie's **Free** or **Essentials** plan, you can add this integration from your team dashboard only. The **Integrations** page under **Settings** is not available in your plan.
   2. Make sure you have enabled "Allow Create and Update Access"

### Get Your API Key

1. In Opsgenie, Go to **Settings → Integrations**.
2. Make sure Status is ON
3. Click on your selected integration from the list.
4. Copy API Key from the Integration settings panel.

<figure><img src="/files/4ChOlU404PRCr3IcVn0y" alt=""><figcaption></figcaption></figure>

### Create a new Connected App in groundcover

1. In groundcover, Go to **Settings → Connected Apps**.
2. Click on Opsgenie integration
3. Fill the form:
   1. Integration name in groundcover
   2. API Key
   3. The Site where your integration is<br>

      <figure><img src="/files/nV7SOOEFluDmI1TGLHtW" alt="" width="375"><figcaption></figcaption></figure>
4. **Configure Severity Mapping** (Optional)

   groundcover uses severity levels (S1-S4) while OpsGenie uses priority levels (P1-P5). Configure the mapping to translate severities to your preferred OpsGenie priorities:

   | groundcover Severity | Default OpsGenie Priority |
   | -------------------- | ------------------------- |
   | S1 (Critical)        | P1                        |
   | S2 (Error)           | P2                        |
   | S3 (Warning)         | P3                        |
   | S4 (Info)            | P4                        |

   You can customize this mapping in the Connected App configuration to match your organization's priority definitions.
5. **Test the connection** (Optional)
   * This will send a notification similar to the notification that will be sent by monitors with `[TEST] Notification from groundcover` in the title to differentiate from 'real' notifications.
6. **Save**

### OpsGenie Alert Payload

groundcover sends alerts to OpsGenie using the following format:

```json
{
  "message": "{{ summary }}",
  "alias": "{{ fingerprint }}",
  "description": "{{ description }}",
  "priority": "P1|P2|P3|P4|P5",
  "source": "groundcover",
  "tags": ["{{ severity }}", "{{ labels.cluster }}", "{{ labels.namespace }}"],
  "details": {
    "monitor_name": "{{ monitor_name }}",
    "monitor_id": "{{ monitor_id }}",
    "value": "{{ value }}",
    "threshold": "{{ threshold }}",
    "status": "alerting|resolved",
    "renotification_count": 0,
    "issue_url": "{{ urls.issue }}",
    "monitor_url": "{{ urls.monitor }}",
    "labels": {
      "cluster": "{{ labels.cluster }}",
      "namespace": "{{ labels.namespace }}",
      "workload": "{{ labels.workload }}"
    }
  }
}
```

{% hint style="info" %}
This payload structure is fixed and cannot be customized. Values shown with `{{ }}` are dynamically populated from your monitor configuration. If you need a custom payload structure, use a [Generic Webhook](/integrations/connected-apps/generic-webhook.md) instead.

**Test mode:** When using "Test the connection", the `status` field will be "test" and other fields like `value`, `threshold`, and URLs may contain placeholder values.
{% endhint %}

#### Payload Field Reference

| Field                  | Description                                                                                                                                            |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `message`              | Issue title from the alert                                                                                                                             |
| `alias`                | Alert fingerprint for deduplication                                                                                                                    |
| `description`          | Monitor description with variable expansion                                                                                                            |
| `priority`             | Mapped from groundcover severity (see table above)                                                                                                     |
| `source`               | Always "groundcover"                                                                                                                                   |
| `tags`                 | Array of OpsGenie alert tags for routing and filtering (includes severity and select labels). Tags are populated from labels that exist on the monitor |
| `monitor_name`         | Name of the monitor                                                                                                                                    |
| `monitor_id`           | Internal unique ID of the monitor                                                                                                                      |
| `value`                | The value that triggered the alert                                                                                                                     |
| `threshold`            | Configured threshold for the monitor                                                                                                                   |
| `status`               | Alert state: "alerting", "resolved", or "test" (during connection testing)                                                                             |
| `renotification_count` | Counter for re-notifications (starts at 0)                                                                                                             |
| `issue_url`            | Link to investigate the issue                                                                                                                          |
| `monitor_url`          | Link to the monitor configuration                                                                                                                      |
| `labels`               | Monitor labels as key-value pairs. Only labels defined in the monitor's group-by or custom labels are included; keys may be absent if not defined      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/integrations/connected-apps/opsgenie-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
