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

# DBmarlin alert integration

> Send DBmarlin instance and host alert start and end events to Flashduty On-call through its Webhook integration.

Use DBmarlin's Webhook integration to send database instance and host alerts to Flashduty On-call. The "started" and "ended" notifications of one alert rule on the same instance or host update one Flashduty alert, which recovers when the alert ends.

DBmarlin's webhook has no fixed format: you write the request body in the **Content Template**. The templates on this page are the format Flashduty parses, so copy them as is.

<div className="hide">
  ## In Flashduty On-call

  ***

  Create either a dedicated or shared **DBmarlin** alert integration and copy its complete Push URL.
</div>

## Configure DBmarlin

***

The Webhook integration requires DBmarlin v5.11 or later, and a DBmarlin server can have only one Webhook integration.

<Steps>
  <Step title="Open the Webhook integration">
    In DBmarlin, go to **Settings → Integrations** and click **Edit** on the **Webhook** row.
  </Step>

  <Step title="Enter the URL and headers">
    * **Webhook URL**: the complete Flashduty Push URL, such as `https://api.flashcat.cloud/event/push/alert/dbmarlin?integration_key=<your-integration-key>`
    * **DBmarlin URL**: the address you use to open DBmarlin, used for the link back into DBmarlin
    * **Headers**: add `Content-Type: application/json`
  </Step>

  <Step title="Enter the Content Template (instance alerts)">
    The **Content Template** is used for instance alerts. Paste this JSON:

    ```json theme={null}
    {
      "body": {
        "instance": "<datasourcename>",
        "ruleid": "<ruleid>",
        "rulename": "<rulename>",
        "statistic": "<statistic>",
        "startedended": "<startedended>",
        "oldvalue": "<oldvalue>",
        "newvalue": "<newvalue>",
        "threshold": "<threshold>",
        "units": "<units>",
        "url": "<url>"
      }
    }
    ```
  </Step>

  <Step title="Enter the Host Content Template (host alerts)">
    The **Host Content Template** is used for host alerts. Paste this JSON:

    ```json theme={null}
    {
      "body": {
        "node": "<hostname>",
        "ruleid": "<ruleid>",
        "rulename": "<rulename>",
        "statistic": "<statistic>",
        "startedended": "<startedended>",
        "oldvalue": "<oldvalue>",
        "newvalue": "<newvalue>",
        "threshold": "<threshold>",
        "units": "<units>",
        "url": "<url>"
      }
    }
    ```

    <Warning>
      Keep `ruleid`, `startedended`, and either `instance` (instance alerts) or `node` (host alerts). Flashduty rejects a request without the rule ID or the instance/host name, because it could not reliably match the later "ended" notification. The template must be valid JSON.
    </Warning>
  </Step>

  <Step title="Enable and verify">
    Save and enable the integration. Under **Settings → Alert Rules**, create a rule that is easy to trigger, wait for DBmarlin to send the "started" notification, and confirm Flashduty shows an active alert. When the rule clears, DBmarlin sends the "ended" notification; confirm the same alert recovers. The DBmarlin docs do not mention a test button for the Webhook, so verify with a real alert.
  </Step>
</Steps>

## Alert Key

***

Flashduty computes the Alert Key from the rule ID (`ruleid`) plus the instance name (`instance`) or host name (`node`); instance alerts and host alerts never share a key. The "started" and "ended" notifications of one rule on the same instance or host share one Alert Key; changes to `from`, `to`, values, and the rule name do not change it.

* If you delete a rule and recreate it, it gets a new rule ID and the old alert is not resolved; close it manually
* When the same rule fires again, it uses the same Alert Key

## Status and severity

***

| DBmarlin `startedended` | Flashduty status or severity |
| :- | :- |
| Start (such as `started`) | Warning |
| End (such as `ended`) | Recovery, original severity Warning |

DBmarlin has only the warning level, so every alert is treated as Warning. The DBmarlin docs do not list the values of `startedended`; Flashduty treats a value starting with `end` as the end and any other value as a start.

## Recovery and auto-close

***

DBmarlin sends an "ended" notification when an alert ends, and Flashduty uses it to recover the alert. To keep a lost notification from leaving an alert open, configure **auto-close after timeout** on the channel or integration, longer than your rules can stay active.

## Troubleshooting

***

* **DBmarlin logs `status code 400`**: confirm the template is valid JSON and contains `ruleid`, plus `instance` (instance alerts) or `node` (host alerts)
* **`404` or `401`**: confirm the Webhook URL is complete and contains `integration_key`
* **The alert does not recover**: confirm DBmarlin sent the "ended" notification and the template contains `startedended`; a double quote or backslash in a rule name breaks the JSON, so avoid them
* **Host alerts do not arrive**: host alerts use the **Host Content Template**, not the **Content Template**

For more details, see the [DBmarlin Webhook documentation](https://docs.dbmarlin.com/docs/Integrations/webhook).
