> ## 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.

# Redgate SQL Monitor 告警集成

> 通过 Webhook 将 Redgate Monitor（原 SQL Monitor）的告警同步到 Flashduty On-call，告警结束时自动恢复。

通过 Redgate Monitor（原 Redgate SQL Monitor）的 Webhook 通知，将 SQL Server、Azure SQL 等数据库的告警同步到 Flashduty On-call。Redgate Monitor 中的每条告警对应一条 Flashduty 告警：告警产生（Raised）时触发，等级升高（Escalated）或降低（DeEscalated）时更新，告警结束（Ended）时自动恢复。

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

  ***

  您可通过以下两种方式获取集成推送地址，任选其一即可。

  ### 使用专属集成

  1. 进入 Flashduty 控制台，选择 **协作空间**，打开一个协作空间
  2. 选择 **配置** → **集成数据** → **专属集成**，点击 **新增一个集成**
  3. 选择 **Redgate SQL Monitor**，点击 **保存**
  4. 打开生成的集成卡片，复制 **推送地址**

  ### 使用共享集成

  1. 进入 Flashduty 控制台，选择 **集成中心 → 告警事件**
  2. 选择 **Redgate SQL Monitor**，填写集成名称
  3. 配置默认路由并选择协作空间；创建后可在 **路由** 中增加更多规则
  4. 点击 **保存**，复制生成的 **推送地址**
</div>

## 在 Redgate Monitor 中配置

***

Webhook 通知在 Redgate Monitor 的 Web 控制台中配置，对该 Base Monitor 产生的所有告警生效，需要管理员权限。Base Monitor 服务所在的机器需要能访问 Flashduty 的推送地址。

<Steps>
  <Step title="打开通知设置">
    1. 登录 Redgate Monitor 的 Web 控制台，进入 **Configuration** 页面
    2. 在 **Alerts** 下选择 **Notification settings**，找到 **Webhook notifications** 部分
  </Step>

  <Step title="填写 Webhook">
    1. 选择 Redgate Monitor 在什么情况下发送 Webhook 消息
    2. 消息格式选择 **默认消息（Default message）**。Flashduty 按默认消息的 JSON 字段解析，不支持自定义消息（Custom message）
    3. 将 Flashduty 集成的完整推送地址粘贴到 **URL**，地址中需包含 `integration_key`
    4. 无需添加额外的 HTTP 请求头，Flashduty 通过地址中的 `integration_key` 认证
    5. 保存设置
  </Step>

  <Step title="验证">
    1. 点击 **Send Test Notification**，确认 Redgate Monitor 能把消息发送到 Flashduty。Redgate 没有公开测试消息的内容；如果测试消息在 Flashduty 中创建了告警，请手动关闭它
    2. 等待一条真实告警产生，确认 Flashduty 收到活动告警；告警在 Redgate Monitor 中结束后，确认原告警恢复
  </Step>
</Steps>

<Note>
  如果 Base Monitor 通过代理访问外网，需要在 Base Monitor 所在机器上配置代理，参考 [Setting up Webhook notifications](https://documentation.red-gate.com/monitor/setting-up-webhook-notifications-239668082.html) 中的 Proxy configuration 一节。
</Note>

## Alert Key

***

Redgate Monitor 的告警 ID（`id`）只在单个 Base Monitor 内唯一，因此 Flashduty 使用 Base Monitor 标识（`baseMonitorGuid`）和告警 ID（`id`）共同计算 Alert Key。同一条告警的 Raised、Escalated、DeEscalated、Ended 消息使用同一个 Alert Key，多个 Base Monitor 推送到同一个集成时也不会互相合并。告警名称、等级、描述、时间等字段变化不会改变 Alert Key。缺少 `id` 或 `baseMonitorGuid` 的消息会被拒绝。

## 状态和告警等级

***

| `statusChange` | 含义 | Flashduty 状态 |
| :- | :- | :- |
| `Raised` | 告警产生 | 触发 |
| `Escalated` | 告警等级升高 | 触发，按新等级更新 |
| `DeEscalated` | 告警等级降低 | 触发，按新等级更新 |
| `Ended` | 告警结束 | 恢复 |

| Redgate Monitor 等级（`severity`） | Flashduty 等级 |
| :- | :- |
| `High` | Critical |
| `Medium` | Warning |
| `Low` | Info |

`Ended` 消息的 `severity` 为 `None`，Flashduty 使用 `previousSeverity`（告警结束前的等级）作为恢复事件的等级。等级为空或无法识别时按 Warning 处理。`messageType` 不是 `AlertNotification` 的消息不会创建告警，Flashduty 收到后直接返回成功。

## 标签

***

| 标签 | 来源 |
| :- | :- |
| `check` | 告警名称，如 `Long-running query` |
| `resource` | 被监控对象的名称（如 `machine\instance`）；Azure SQL 为 `服务器/数据库` |
| `host` | 机器名 |
| `group` | Redgate Monitor 中的分组名称 |
| `cluster` | 集群名称 |
| `sql_instance` | SQL Server 实例名称 |
| `azure_sql_server` / `azure_sql_database` / `azure_elastic_pool` | Azure SQL 服务器、数据库和弹性池名称 |
| `tags` | 实例的标签，逗号分隔 |
| `cir` | Redgate Monitor 内部的被监控对象路径 |
| `alert_id` / `base_monitor_guid` | 告警 ID 和 Base Monitor 标识，即 Alert Key 的来源 |
| `status_change` | 本次消息的状态变化 |
| `severity` | Redgate Monitor 原始等级 |
| `url` | Redgate Monitor 中该告警详情页的链接 |

告警描述为 Redgate Monitor 的告警类型说明；自定义指标配置了辅助查询时，附带其返回的详细信息（`alertDetailText`）。

## 排查问题

***

* **测试消息发送失败**：确认 Base Monitor 所在机器能访问 Flashduty 推送地址，需要代理时按上文配置代理
* **Flashduty 返回参数错误**：确认 URL 完整且包含 `integration_key`，并且消息格式选择的是默认消息
* **告警没有恢复**：Redgate Monitor 会在收到告警 20 秒后发送 Webhook，失败时 10 分钟后重试一次；如果两次都失败，这条消息会丢失，需要在 Flashduty 中手动关闭告警。另外，每类告警对每个被监控对象在 24 小时内的通知数量有上限（默认 30），告警频繁变化时可适当调高
* **收到告警较慢**：Webhook 消息在告警产生约 20 秒后发送，属于正常现象

更多字段含义请参阅 [Redgate Monitor Webhook 通知](https://documentation.red-gate.com/monitor/setting-up-webhook-notifications-239668082.html)。
