Update Alert Rule

Update a alert rule. Any parameter (if not being null) included request body can be updated. The fields required to be verified include: model ID (modelId), measurepoint (measurepointId), alert severity (severityId), alert content (contentId) and query scope (scope).

Operation Permissions

Required Authorization Required Operation Permission
orgId Full Access

Request Format

POST https://{apigw-address}/event-service/v2.1/alert-rules?action=update

Request Parameters (URI)

Name Location (Path/Query) Required or Not Data Type Description
orgId Query true String Organization ID which the asset belongs to. How to get orgId>>
isPatchUpdate Query true Boolean Whether to perform partial update.
When it is true, only the fields specified in the parameter are updated;
when it is false, all the fields will be updated, i.e. the fields without specified value will be left blank. Set as true by default.

Request Parameters (Body)

Note

In the following non-required fields, you must provide measurepointId or deviceStatus to trigger the alert.

Name Required or Not (Specially in case that isPatchUpdate=false) Data type Description
ruleId true String Alert rule ID, which is specified by the user as the unique identifier to locate the alert rule to be updated.
ruleDesc true StringI18n Internationalized alert description, for which only supports full update. For the structure, see Internationalized name struct>>
modelId true String Model applicable for the alert rule. How to get modelID>>
measurepointId false String Asset measurement point. How to get pointId>>
deviceStatus false Object Device status, such as “offline”. See Setting State-based Alerts.
condition true String Query expression-like statement. For example, “${temperature} = 19” indicates that the value of the measurement point “temperature” is 19. A slash “/” is used to express the hierarchical relationship, for which only one downward layer is supported now. For example, “${pointA/att1} = 18” indicates the “att1” attribute value of the measurement point “A” is 18. How to use expression>>
severityId true String Alert severity ID
contentId true String Alert content ID
tags false tags struct Rule tags, for which only full update is supported. For details, see How to use tag>>
scope true AssetNode struct Specify a node on the asset tree to indicate the scope of the alert rule. See AssetNode struct.
isEnabled false Boolean Whether it is allowed to take effect. It is set as “true” by default
triggeringDelayTimer false Integer Time to delay the alert triggering. The unit is seconds and the range is [60 - 10800]. The alert will be triggered when an anomaly that matches the alert rule occurs, and this anomaly does not return to normal within the set time. When it is 0, trigger the alert immediately. See Tutorial: Setting Alert Triggering Delay Timer.

AssetNode Struct

Name Required or Not Data Type Description
treeId true String Asset tree ID. If it is set as “all”, it indicates that this is a special node, standing for the globality of the organization.
assetId true String Asset ID. How to get assetId>>

Response Parameters

Name Data Type Description
data null Null

Sample

Request Sample

POST https://{apigw-address}/event-service/v2.1/alert-rules?action=update&orgId=1c499110e8800000&isPatchUpdate=false
{
    "alertRule": {
        "ruleId": "user BID",
        "ruleDesc": {
            "defaultValue": "Grid is connected from converter",
            "i18nValue": {
                "en_US": "Grid is connected from converter",
                "zh_CN": "电网由变频器连接"
            }
        },
        "modelId": "EnOS_Solar_CombinerBox",
        "measurepointId": "CBX.BranchStateAttr",
        "condition": "${CBX.BranchStateAttr} = 18",
        "severityId": "WARN",
        "contentId": "planetTemperature",
        "tags": {
            "key1": "v1"
        },
        "orgId": "1c499110e8800000",
        "scope": [{
            "treeId": "ptde66nd",
            "assetId": "FbFy8qyz"
        }],
        "isEenabled": true
     }
}

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "4873095e-621d-4cfd-bc2c-edb520f574ea",
    "data": ""
}