# 告警 创建告警规则,以便在[指标](https://docs.equinix.com/zh-Hans/observability/streaming-data/metrics.md)超过定义阈值时发送告警事件。警报可以在和上触发`criticalThreshold`,如果指标值低于或超过预期阈值,则会触发警报`warningThreshold`事件。 > **注意** > > 要接收由告警触发的事件,您需要能够在所选接收器中接收来自已订阅的流的事件。告警触发的事件在客户门户网站或API中不可用。 要查看支持的指标列表,请参阅“[指标](https://docs.equinix.com/zh-Hans/observability/streaming-data/metrics.md)”页面。 ## 创建警报[​](#创建警报 "直接链接至创建警报") 前提条件:要添加告警规则,您应创建一个数据流,其中已关联端口和/或连接资源并启用指标 * Portal * API 1. 在“*可观测性*”菜单中,单击**数据流**。 2. 从\_数据流清单\_中选择数据流。 ![](https://docs.equinix.com/zh-Hans/assets/images/stream-inventory-49d715a84f2a27ab0ad7065aa1b5a12c.png) 3. 在“*流详情*”页面上,从“*操作*”下拉菜单中,单击**添加告警**。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-add-alert-d701c09d768421435f2fd8270e33d51e.png) 4. 在\_添加告警\_页面上,输入规则参数。 * 从“*选择指标*”下拉菜单中选择连接或端口指标。 * 给你的提醒命名。 * 添加警报描述(可选)。 * 选择操作数值:`ABOVE`或`BELOW`。 * 从下拉菜单中选择窗口大小。 * 在\_警告阈值\_字段中设置触发警告事件的值。 * 在\_严重阈值\_字段中设置触发严重事件的值。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-add-details-1260da4bcd4f5900148fd838e9078239.png) 5. 点击“**下一步”** 6. 从列表中选择要应用警报的连接或端口。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-add-resources-9a1f936ea57fccc5f180adc048bf93c5.png) 7. 单击**提交**。 在确认屏幕中,您可以向告警添加更多资源,向数据流添加订阅以接收告警,或添加其他告警。要查看新告警的详细信息,请单击**查看告警详情**。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-confirmation-56da2a51526d3a408d68aab8e685f88d.png) 要创建告警,请向端点发送`POST`请求[`/fabric/v4/streams/{streamId}/alertRules`](https://docs.equinix.com/zh-Hans/api-catalog/fabricv4/stream-alert-rules/createstreamalertrules.md)。 cURL 请求示例: ``` curl -X 'POST' 'https://api.equinix.com/fabric/v4/streams//alertRules' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ -d '{ "type": "METRIC_ALERT", "name": "", "description": "", "enabled": "true", "metricSelector": { "include": [ "equinix.fabric.port.bandwidth_tx.usage" ] }, "resourceSelector": { "include": [ "/fabric/v4/ports/780d384f-2eb6-4c07-ac89-ea106ca12814" ] }, "detectionMethod": { "type": "THRESHOLD", "operand": "ABOVE", "windowSize": "PT5M", "warningThreshold": 200000, "criticalThreshold": 300000 } }' ``` 示例回答: ``` { "href": "https://api.equinix.com/fabric/v4/streams/128cfe7c-e24f-4b1b-8a4f-680cd650c46c/alertRules/28da40d8-09bf-49f2-a02d-af34210f275e", "uuid": "128cfe7c-e24f-4b1b-8a4f-680cd650c46c", "type": "METRIC_ALERT", "name": "", "description": "", "state": "ACTIVE", "enabled": true, "metricSelector": { "include": [ "equinix.fabric.port.bandwidth_tx.usage" ] }, "resourceSelector": { "include": [ "/fabric/v4/ports/780d384f-2eb6-4c07-ac89-ea106ca12814" ] }, "detectionMethod": { "type": "THRESHOLD", "operand": "ABOVE", "windowSize": "PT5M", "warningThreshold": 200000, "criticalThreshold": 300000 } "changeLog": { "createdBy": "testuser", "createdDateTime": "2025-02-04T23:17:54.323427936Z" } } ``` ### 创建智能警报 - 延迟[​](#创建智能警报---延迟 "直接链接至创建智能警报 - 延迟") 对于您已[关联都会区的](https://docs.equinix.com/zh-Hans/observability/streaming-data/api-managing-assets.md)流,您可以为延迟阈值创建智能告警。这些由人工智能驱动的告警分析都会区网点的历史时延数据,利用机器学习来建立基准性能并生成智能告警阈值,从而无需手动配置告警。 * Portal * API 要创建智能告警规则,请按照[创建告警的](#creating-an-alert)相同步骤操作,以及: 1. 从\_选择指标\_下拉菜单中选择**Fabric都会区延迟**指标。 2. 提供告警名称和描述(可选)。单击**下一步**。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-smart-latency-c42d0ce4f3d56c8da9eb3c2a622cebdc.png) 3. 选择一个或多个城市,并应用智能警报规则。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-smart-metro-afc211583d4ddce8b1c986af8654b5cf.png) 4. 点击“**提交”** 您的警报已显示在警报列表中。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-smart-list-4f495a14e11fe1257c1d0aff55e77dee.png) 要创建智能告警规则,请向端点发送`POST`请求[`/fabric/v4/streams/{streamId}/alertRules`](https://docs.equinix.com/zh-Hans/api-catalog/fabricv4/stream-alert-rules/createstreamalertrules.md)。 在对象中指定要为其创建告警的都会区特有指标`metricSelector`,连接到要在对象中作为资源添加的流的都会区`resourceSelector`,并指定`detectionMethod.type`为`OUTLIER`。 ``` curl -X 'POST' 'https://api.equinix.com/fabric/v4/streams//alertRules' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ -d '{ "type": "METRIC_ALERT", "name": "", "description": "", "enabled": true, "metricSelector": { "include": [ "equinix.fabric.metro._.latency" ] }, "resourceSelector": { "include": [ "/fabric/v4/metros/{metro_code}" ] }, "detectionMethod": { "type": "OUTLIER" } }' ``` ## 获取您的提醒[​](#获取您的提醒 "直接链接至获取您的提醒") * Portal * API 要查看流的警报列表: 1. 在“*可观测性*”菜单中,单击**数据流**。 2. 从\_数据流清单\_中选择数据流。 ![](https://docs.equinix.com/zh-Hans/assets/images/stream-inventory-49d715a84f2a27ab0ad7065aa1b5a12c.png) 3. 单击**告警**。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-list-5524a9aad0ccf5b74a49a4966b74d92e.png) 要获取告警详细信息,请向端点发送`GET`请求[`/fabric/v4/streams/{streamId}/alertRules/{alertRuleId}`](https://docs.equinix.com/zh-Hans/api-catalog/fabricv4/stream-alert-rules/getstreamalertrulebyuuid.md)。 cURL 请求示例: ``` curl -X 'GET' 'https://api.equinix.com/fabric/v4/streams//alertRules/' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' ``` 示例回答: ``` { "href": "https://api.equinix.com/fabric/v4/streams/128cfe7c-e24f-4b1b-8a4f-680cd650c46c/alertRules/28da40d8-09bf-49f2-a02d-af34210f275e", "uuid": "128cfe7c-e24f-4b1b-8a4f-680cd650c46c", "type": "METRIC_ALERT", "name": "", "description": "", "state": "ACTIVE", "enabled": true, "metricSelector": { "include": [ "equinix.fabric.port.bandwidth_tx.usage" ] }, "resourceSelector": { "include": [ "/fabric/v4/ports/780d384f-2eb6-4c07-ac89-ea106ca12814" ] }, "detectionMethod": { "type": "THRESHOLD", "operand": "ABOVE", "windowSize": "PT5M", "warningThreshold": 200000, "criticalThreshold": 300000 } "changeLog": { "createdBy": "testuser", "createdDateTime": "2025-02-04T23:17:54.323427936Z" } } ``` ## 删除提醒[​](#删除提醒 "直接链接至删除提醒") * Portal * API 删除提醒: 1. 在“*可观测性*”菜单中,单击**数据流**。 2. 从\_数据流清单\_中选择数据流。 ![](https://docs.equinix.com/zh-Hans/assets/images/stream-inventory-49d715a84f2a27ab0ad7065aa1b5a12c.png) 3. 单击**告警**。 4. 在告警列表中,单击要删除的选项菜单,然后单击**移除告警**。 ![](https://docs.equinix.com/zh-Hans/assets/images/alerts-remove-fdea58374bc7c8af0e287139377896d9.png) 要删除告警,请向端点发送`DELETE`请求[`/fabric/v4/streams/{streamId}/alertRules/{alertRuleId}`](https://docs.equinix.com/zh-Hans/api-catalog/fabricv4/stream-alert-rules/deletestreamalertrulebyuuid.md)。 cURL 请求示例: ``` curl -X DELETE 'https://api.equinix.com/fabric/v4/streams//alertRules/' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' ``` 示例回答: ``` { "href": "https://api.equinix.com/fabric/v4/streams/128cfe7c-e24f-4b1b-8a4f-680cd650c46c/alertRules/28da40d8-09bf-49f2-a02d-af34210f275e", "uuid": "28da40d8-09bf-49f2-a02d-af34210f275e", "type": "METRIC_ALERT", "name": "", "description": "", "state": "INACTIVE", "enabled": true, "metricName": "equinix.fabric.port.bandwidth_tx.usage", "resourceSelector": { "include": [ "*/ports/" ] }, "windowSize": "PT15M", "operand": "ABOVE", "warningThreshold": "43000000", "criticalThreshold": "45000000", "changeLog": { "createdBy": "testuser", "createdDateTime": "2025-02-04T23:17:54.323427936Z" } } ```