Rule resources
A rule combines one or more triggers with one or more destinations and a customized message. When conditions match any trigger in a rule, Zenoss Cloud sends a message to all the destinations in the rule.
Only rules can initiate actions.
Resource list
- Create a rule (POST /v1/notification/rules)
- Get one rule (GET /v1/notification/rules/{name})
- Get multiple rules (GET /v1/notification/rules[?query])
- Update a rule (PUT /v1/notification/rules/{name})
- Delete a rule (DELETE /v1/notification/rules/{name})
POST /v1/notification/rules
Creates a rule.
Fields
Field | Required? | Value | Description |
---|---|---|---|
name |
Yes | String | A unique, short identifier for the rule. Once created, a rule's |
description |
No | String | Additional text to further describe the rule. |
enabled |
No | Boolean | The state of the rule, enabled (true ) or disabled (false ). The default is false . |
triggerNames |
No | Array | A list of triggers to associate with the rule. |
destinationNames |
No | Array | A list of destinations to associate with the rule. |
message |
No | String | The text to send to destinations. You can include one or more templates in the text. |
repeat |
No | Boolean | Repeat the action (send notifications) each time a trigger matches. The default is false , do not repeat. |
repeatInterval |
No | Number | The amount of time to wait before repeating the action (send notifications), in seconds. Only in effect when the To ensure that notifications for all matching triggers are sent, set the value of this field to zero. Actions for matching triggers are suppressed until this interval elapses. The default value is 3600 seconds (1 hour). |
sendUpdates |
No | Boolean | Perform the action (send notifications) when the conditions that previously matched a trigger change significantly.
For example, when an event is closed, acknowledged, or changes severity. The default is false , do not send updates. |
tags |
No | Array | A list of arbitrary terms associated with the rule. |
Status codes
- 200 (OK: rule was created)
- 400 (Bad Request: invalid rule)
- 409 (Conflict: a rule with the same name already exists)
Example
cat << EOF | curl https://YOUR-API-ENDPOINT/v1/notification/rules \
-H "zenoss-api-key: $ZENOSS_API_KEY" -X POST -s -d @-
{
"name": "rule-1",
"description": "Rule combining trigger-1 with destination-1.",
"enabled": true,
"triggerNames": ["trigger-1"],
"destinationNames": ["destination-1"],
"message": "This is that notification you wanted.",
"repeat": true,
"repeatInterval": 3600,
"sendUpdates": true,
"tags": ["example"]
}
EOF
{
"rule": {
"name": "rule-1",
"description": "Rule combining trigger-1 with destination-1.",
"triggerNames": [
"trigger-1"
],
"destinationNames": [
"destination-1"
],
"message": "This is that notification you wanted.",
"enabled": true,
"repeat": true,
"repeatInterval": "3600",
"sendUpdates": true,
"tags": [
"example"
]
}
}
GET /v1/notification/rules/{name}
Gets one rule.
Status codes
- 200 (OK: rule exists)
- 404 (Not Found: rule doesn't exist)
Example
curl https://YOUR-API-ENDPOINT/v1/notification/rules/YOUR-RULE-NAME \
-H "zenoss-api-key: YOUR-API-KEY" -X GET -s
{
"rule": {
"name": "YOUR-RULE-NAME",
"description": "Rule combining trigger-1 with destination-1.",
"triggerNames": [
"trigger-1"
],
"destinationNames": [
"destination-1"
],
"message": "This is that notification you wanted.",
"enabled": true,
"repeat": true,
"repeatInterval": "3600",
"sendUpdates": true,
"tags": [
"example"
]
}
}
GET /v1/notification/rules[?query]
Gets all rules or rules that match a query.
Queries may be appended to the base URL with standard query syntax. See the query string example.
Fields
Query fields
Field | Value | Comparison | Repeat? |
---|---|---|---|
name |
String | Contains | No (may be used only once) |
description |
String | Contains | No |
enabled |
Boolean | Equal to | No |
triggerNames |
String | Contains | Yes (may be used multiple times) |
destinationNames |
String | Contains | Yes |
message |
String | Contains | No |
repeat |
Boolean | Equal to | No |
repeatInterval |
Number | Equal to | No |
sendUpdates |
Boolean | Equal to | No |
tags |
String | Contains | Yes |
For more information about query fields, see the create a rule resource.
Response fields
Field | Description |
---|---|
recentNotificationCount |
The total number of notifications sent in the last 24 hours that used a rule, if any. |
totalCount |
The total number of rules returned. |
Status Codes
- 200 (OK)
All rules example
curl https://YOUR-API-ENDPOINT/v1/notification/rules \
-H "zenoss-api-key: YOUR-API-KEY" -X GET -s
{
"rules": [
{
"name": "rule-1",
"description": "Rule combining trigger-1 with destination-1.",
"triggerNames": [
"trigger-1"
],
"destinationNames": [
"destination-1"
],
"message": "This is that notification you wanted.",
"enabled": false,
"repeat": true,
"repeatInterval": "3600",
"sendUpdates": true,
"tags": [
"example"
]
}
],
"totalCount": "1"
}
Query string example
curl https://YOUR-API-ENDPOINT/v1/notification/rules?enabled=false&repeat=true \
-H "zenoss-api-key: YOUR-API-KEY" -X GET -s
{
"rules": [
{
"name": "rule-1",
"description": "Rule combining trigger-1 with destination-1.",
"triggerNames": [
"trigger-1"
],
"destinationNames": [
"destination-1"
],
"message": "This is that notification you wanted.",
"enabled": false,
"repeat": true,
"repeatInterval": "3600",
"sendUpdates": true,
"tags": [
"example"
]
}
],
"totalCount": "1"
}
PUT /v1/notification/rules/{name}
Updates the specification of an existing rule.
Rule names cannot be changed.
Fields
Although each field is optional, requests fail if none is specified.
Field | Required? | Value | Description |
---|---|---|---|
description |
No | String | Additional text to further describe the rule. |
enabled |
No | Boolean | The state of the rule, enabled (true ) or disabled (false ). The default is false . |
triggerNames |
No | Array | A list of triggers to associate with the rule. |
destinationNames |
No | Array | A list of destinations to associate with the rule. |
message |
No | String | The text to send to destinations. You can include one or more templates in the text. |
repeat |
No | Boolean | Repeat the action (send notifications) for each matching trigger. The default is false . |
repeatInterval |
No | Number | The amount of time to wait before repeating the action (send notifications), in seconds. Only in effect when the To ensure that notifications for all matching triggers are sent, set the value of this field to zero. Actions for matching triggers are suppressed until this interval elapses. The default value is 3600 seconds (1 hour). |
sendUpdates |
No | Boolean | Perform the action (send notifications) when the conditions that previously matched a trigger change significantly.
For example, when an event is closed, acknowledged, or changes severity. The default is false , do not send updates. |
tags |
No | Array | A list of arbitrary terms associated with the rule. |
Status codes
- 200 (OK: rule was updated)
- 400 (Bad Request: invalid rule)
- 404 (Not Found: rule doesn't exist)
Example
cat << EOF | curl https://YOUR-API-ENDPOINT/v1/notification/rules/YOUR-RULE-NAME \
-H "zenoss-api-key: YOUR-API-KEY" -X PUT -s -d @-
{
"description": "Updated rule combining trigger-1 with destination-1.",
"enabled": true,
"triggerNames": ["trigger-1"],
"destinationNames": ["destination-1"],
"message": "This is that updated notification you wanted.",
"repeat": true,
"repeatInterval": 3600,
"sendUpdates": true,
"tags": ["example"]
}
EOF
{
"rule": {
"name": "YOUR-RULE-NAME",
"description": "Updated rule combining trigger-1 with destination-1.",
"triggerNames": [
"trigger-1"
],
"destinationNames": [
"destination-1"
],
"message": "This is that updated notification you wanted.",
"enabled": true,
"repeat": true,
"repeatInterval": "3600",
"sendUpdates": true,
"tags": [
"example"
]
}
}
DELETE /v1/notification/rules/{name}
Deletes a rule.
Status codes
- 200 (OK: rule was deleted)
- 404 (Not Found: rule doesn't exist)
Example
curl https://YOUR-API-ENDPOINT/v1/notification/rules/YOUR-RULE-NAME \
-H "zenoss-api-key: YOUR-API-KEY" -X DELETE -s
{}