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

# Opmanager 告警事件

> 通过 webhook 的方式同步 Opmanager 告警事件到 Flashduty On-call，实现告警事件自动化降噪处理

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

  ***

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

  ### 使用专属集成

  当您不需要将告警事件路由到不同的协作空间，优先选择此方式，更简单。

  <AccordionGroup>
    <Accordion title="展开">
      1. 进入 Flashduty 控制台，选择 **协作空间**，进入某个空间的详情页面
      2. 选择 **集成数据** tab，点击 **添加一个集成**，进入添加集成页面
      3. 选择 **OpManager** 集成，点击 **保存**，生成卡片。
      4. 点击生成的卡片，可以查看到 **推送地址**，复制备用，完成。
    </Accordion>
  </AccordionGroup>

  ### 使用共享集成

  当您需要根据告警事件的 Payload 信息，将告警路由到不同的协作空间，优先选择此方式。

  <AccordionGroup>
    <Accordion title="展开">
      1. 进入 Flashduty 控制台，选择 **集成中心=>告警事件**，进入集成选择页面。
      2. 选择 **OpManager** 集成：
         * **集成名称**：为当前集成定义一个名称。
      3. 配置默认路由，并选择对应的协作空间（集成创建后可以前往 `路由` 进行更多路由规则的配置）。
      4. 点击 **保存** 后，复制当前页面的新生成的 **推送地址** 备用。
      5. 完成。
    </Accordion>
  </AccordionGroup>
</div>

## 在 OpManager

***

<div className="md-block">
  ## 一、OpManager 告警推送配置

  1. 登录您的 `OpManager` 控制台，在导航菜单中选择 `Settings => Notification Profiles`。
  2. 在 `Notifications` 页面中，点击 `Add` 后选择 `Invoke a Webhook` 添加配置文件。

  <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/opm-1.png" />

  3. 开始在 Webhook 编辑页面进行配置具体内容。
  4. `Hook URL` 中的请求方法选择 `POST`，`URL` 填写**告警集成的推送地址**。
  5. `Data Type` 选择 `raw`，`Payload Type` 选择 `JSON`。
  6. `Body Content` 填写以下内容：

  ```
  {
       "alarmid":"$alarmid",
       "message":"$message",
       "displayName":"$displayName",
       "category":"$category",
       "severity":"$stringseverity",
       "strModTime":"$strModTime",
       "eventType":"$eventType",
       "entity":"$entity",
       "lastPolledValue":"$lastPolledValue",
       "Intf_ifDescr":"$IntfField(ifDescr)",
       "Intf_displayName":"$IntfField(displayName)",
       "Intf_ifAlias":"$IntfField(ifAlias)",
       "Intf_ifName":"$IntfField(ifName)",
       "Intf_ipAddress":"$IntfField(ipAddress)",
       "Intf_physMedia":"$IntfField(physMedia)",
       "Intf_ifIndex(ifIndex)":"$IntfField(ifIndex)",
       "Intf_ifCircuitID(ifCircuitID)":"$IntfField(ifCircuitID)",
       "Intf_ifSpeedIn(ifSpeedIn)":"$IntfField(ifSpeedIn)",
       "Intf_ifSpeedOut(ifSpeedOut)":"$IntfField(ifSpeedOut)",
       "Intf_lineID":"$IntfCustomField(Circuit ID)",
       "Intf_note":"$IntfCustomField(Comments)",
       "Intf_contacts":"$IntfCustomField(Contact Name)",
       "Intf_SLA":"$IntfCustomField(SLA)",
       "Custom_BuildingNo":"$CustomField(Building)",
       "Custom_cabinet":"$CustomField(Cabinet)",
       "Custom_note":"$CustomField(Comments)",
       "Custom_contacts":"$CustomField(Contact Name)",
       "Custom_department":"$CustomField(Department)",
       "Custom_RoomNo":"$CustomField(Floor)",
       "Custom_serial":"$CustomField(SerialNumbe)",
       "Monitor_monitorName":"$MonitorField(monitorName)",
       "Monitor_instance":"$MonitorField(instance)",
       "Monitor_protocol":"$MonitorField(protocol)",
       "Device_type":"$DeviceField(type)",
       "Device_ipAddress":"$DeviceField(ipAddress)",
       "Device_isSNMP":"$DeviceField(isSNMP)",
       "Device_dependent":"$DeviceField(dependent)",
       "Device_hardDiskSize":"$DeviceField(hardDiskSize)",
       "Device_ramSize":"$DeviceField(ramSize)"
  }
  ```

  **特殊说明** ：暂不支持添加额外的自定义字段，即使在 Body Content 中引用了自定义字段，也不会生效。

  7. `Request Headers` 保持默认的即可。
  8. `Time Out` 填写 1-300 之间的任意值，并点击下一步。

  <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/opm-2.png" />

  9. 在 `Choose the criteria` 配置条件页面中勾选 `Notify when the alarm is cleared`，其他按需配置即可。

  <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/opm-3.png" />

  10. 选择希望应用此配置文件的设备，使用右箭头将它们移动到选定设备窗口，然后点击下一步。
  11. Time Window/Delayed Trigger/Recurring Trigger 可按需配置，然后点击下一步。
  12. 为该配置文件添加名称 `Flashduty`，然后点击 `Save` 保存即可完成配置。
</div>

## 二、状态对照

<div className="md-block">
  | OpManager    | Flashduty | 状态 |
  | ------------ | --------- | -- |
  | Critical     | Critical  | 严重 |
  | Service Down | Critical  | 严重 |
  | Trouble      | Warning   | 警告 |
  | Attention    | Info      | 提醒 |
</div>
