# Grafana OnCall

{% hint style="info" %}
Please note that this is just one possible scenario on how you could use Grafana to feed Incident information to Sleuth. If you have a different process, you might need to adjust the steps/settings.
{% endhint %}

## Registering a new Incident

Within your **Grafana OnCall** dashboard, navigate to the **Outgoing webhooks** page and click **+ New Outgoing Webhook**:

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

In the next step, select **Advanced** to ensure you can customize your webhook as much as possible:

* Provide a (*preferably descriptive*) name for your webhook, e.g. `Sleuth - New Incident`.
* Select a **Trigger Type** from the dropdown. For the purpose of this example, we're choosing `Alert Group Created`.
* Set the **HTTP Method** to `POST`.
* Copy the **Impact registration POST URL** from Sleuth's Custom Impact Source setup modal and paste it into the **Webhook URL** field in Grafana.
* Enter the following into the **Webhook Headers** field in Grafana:

  ```json
  {
    "Content-Type": "application/json"
  }
  ```
* Specify the **Data** you want Grafana to send Sleuth, leveraging the 5 fields the impact registration endpoint is currently able to accept:

  ```json
  {
    "type": "triggered",
    "id": "{{alert_group_id}}",
    "title": "{{alert_payload.oncall.message}}",
    "date": "{{alert_group.created_at}}",
    "url": "{{alert_group.permalinks.web}}"
  }
  ```

{% hint style="warning" %}
Please make sure to **deactivate** **the** `Forward All` **toggle** to ensure only your custom payload is sent to Sleuth's impact registration endpoint.
{% endhint %}

## Closing an Incident

The process is mostly the same as for registering a new Incident, with the difference being the **Name** of the webhook, the **Trigger Ty**pe, which needs to be set to `Resolved`, and the content of the **Data** field, which only needs to contain the following:

* Provide a (*preferably descriptive*) name for your webhook, e.g. `Sleuth - Incident Resolved`.
* Select a **Trigger Type** from the dropdown. For the purpose of this example, we're choosing `Resolved`.
* Set the **HTTP Method** to `POST`.
* Copy the **Impact registration POST URL** from Sleuth's Custom Impact Source setup modal and paste it into the **Webhook URL** field in Grafana.
* Enter the following into the **Webhook Headers** field in Grafana:

  ```json
  {
    "Content-Type": "application/json"
  }
  ```
* Specify the **Data** you want Grafana to send Sleuth, leveraging the 5 fields the impact registration endpoint is currently able to accept:

  ```json
  {
    "type": "resolved",
    "id": "{{alert_group_id}}",
    "title": "{{alert_payload.oncall.message}}",
    "date": "{{alert_group.created_at}}",
    "url": "{{alert_group.permalinks.web}}"
  }
  ```

{% hint style="warning" %}
Please make sure to **deactivate** **the** `Forward All` **toggle** to ensure only your custom payload is sent to Sleuth's impact registration endpoint.
{% endhint %}

{% hint style="info" %}
Both above examples use Grafana's response's default data structure to extract data that correspond to fields for Sleuth's custom incident events. The only mandatory field **is`type`**, all others are optional and can thus be omitted from the response definition.

Without a unique identifier in both payloads, however, Sleuth will not be able to match the **`triggered`** and **`resolved`** events belonging to the **same incident**, and upon receiving a webhook with `resolved`, will **resolve all active Incidents** for that impact source.
{% endhint %}


---

# 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://help.sleuth.io/sleuth-dora/integrations-1/impact-sources/incident-tracker-integrations/custom/grafana-oncall.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.
