Trigger resources
A trigger is a set of criteria that identify conditions in your environment. Triggers usually include queries; for more information see Trigger queries.
Triggers cannot initiate actions. Only rules can initiate actions.
Resource list
- Create a trigger (POST /v1/notification/triggers)
- Get one trigger (GET /v1/notification/triggers/{name})
- Get multiple triggers (GET /v1/notification/triggers[?query])
- Update a trigger (PUT /v1/notification/triggers/{name})
- Delete a trigger (DELETE /v1/notification/triggers/{name})
POST /v1/notification/triggers
Creates a trigger.
Fields
Field | Required? | Value | Description |
---|---|---|---|
name |
Yes | String | A unique, short identifier for the trigger. Once created, a trigger's |
description |
No | String | Additional text to further describe the trigger. |
tags |
No | Array | A list of arbitrary terms to associate with the trigger. |
type |
Yes | Object | The trigger source, one of For more information about specifying a |
Status codes
- 200 (OK: trigger was created)
- 400 (Bad Request: invalid trigger)
- 409 (Conflict: a trigger with the same name already exists)
Example
curl https://YOUR-API-ENDPOINT/v1/notification/triggers \
-H "content-type: application/json" \
-H "zenoss-api-key: YOUR-API-KEY" \
-X POST -s -S -d \
'{
"name": "trigger-1",
"description": "Match events with example in their summary.",
"tags": [
"test"
],
"type": {
"event": {
"query": {
"clause": {
"contains": {
"field": "summary",
"value": "example"
}
}
}
}
}
}'
{
"trigger": {
"name": "trigger-1",
"description": "Match events with example in their summary.",
"type": {
"event": {
"query": {
"clause": {
"contains": {
"field": "summary",
"value": "example"
}
}
}
}
},
"tags": [
"test"
]
}
}
GET /v1/notification/triggers/{name}
Gets one trigger.
Fields
Responses may include the fields in the following table.
Field | Description |
---|---|
ruleNames |
The list of rules that use the trigger. |
recentNotificationCount |
The total number of notifications sent in the last 24 hours that use this trigger. |
Status codes
- 200 (OK: trigger exists)
- 404 (Not Found: trigger doesn't exist)
Example
curl https://YOUR-API-ENDPOINT/v1/notification/triggers/YOUR-TRIGGER-NAME \
-H "zenoss-api-key: YOUR-API-KEY" -X GET -s
{
"trigger": {
"name": "YOUR-TRIGGER-NAME",
"description": "Match events with 'example' in their summary.",
"type": {
"event": {
"query": {
"clause": {
"contains": {
"field": "summary",
"value": "example"
}
}
}
}
}
}
}
GET /v1/notification/triggers[?query]
Gets all triggers or triggers 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 |
type |
String | Contains | No |
ruleNames |
String | Contains | No |
tags |
String | Contains | No |
For more information about query fields, see the create a trigger resource.
Response fields
Field | Description |
---|---|
recentNotificationCount |
The total number of notifications sent in the last 24 hours that used a trigger, if any. |
totalCount |
The total number of triggers returned. |
Status Codes
- 200 (OK)
All triggers example
curl https://YOUR-API-ENDPOINT/v1/notification/triggers \
-H "zenoss-api-key: YOUR-API-KEY" -X GET -s
{
"triggers": [
{
"name": "test-trigger-event-1",
"type": {
"event": {
"query": {
"clause": {
"and": {
"clauses": [
{
"equals": {
"field": "severity",
"value": {
"stringVal": "critical"
}
}
},
{
"equals": {
"field": "status",
"value": {
"stringVal": "open"
}
}
},
{
"equals": {
"field": "source",
"value": {
"stringVal": "my.simple.app.one"
}
}
}
]
}
}
}
}
},
"ruleNames": [
"test-rule-2"
]
},
{
"name": "test-trigger-event-2",
"type": {
"event": {
"query": {
"clause": {
"and": {
"clauses": [
{
"equals": {
"field": "severity",
"value": {
"stringVal": "error"
}
}
},
{
"equals": {
"field": "status",
"value": {
"stringVal": "open"
}
}
},
{
"equals": {
"field": "source",
"value": {
"stringVal": "my.simple.app.two"
}
}
}
]
}
}
}
}
},
"ruleNames": [
"test-rule-1"
],
"recentNotificationCount": "2"
},
{
"name": "test-trigger-event-3",
"type": {
"event": {
"query": {
"clause": {
"or": {
"clauses": [
{
"equals": {
"field": "severity",
"value": {
"stringVal": "error"
}
}
},
{
"equals": {
"field": "status",
"value": {
"stringVal": "open"
}
}
},
{
"equals": {
"field": "source",
"value": {
"stringVal": "my.simple.app.two"
}
}
},
{
"or": {
"clauses": [
{
"startsWith": {
"field": "body",
"value": "Test"
}
}
]
}
}
]
}
}
}
}
}
}
],
"totalCount": "3"
}
Query string example
curl https://YOUR-API-ENDPOINT/v1/notification/triggers?ruleNames=test-rule-2 \
-H "zenoss-api-key: YOUR-API-KEY" -X GET -s
{
"triggers": [
{
"name": "test-trigger-event-1",
"type": {
"event": {
"query": {
"clause": {
"and": {
"clauses": [
{
"equals": {
"field": "severity",
"value": {
"stringVal": "critical"
}
}
},
{
"equals": {
"field": "status",
"value": {
"stringVal": "open"
}
}
},
{
"equals": {
"field": "source",
"value": {
"stringVal": "my.simple.app.one"
}
}
}
]
}
}
}
}
},
"ruleNames": [
"test-rule-2"
]
}
],
"totalCount": "1"
}
PUT /v1/notification/triggers/{name}
Updates an existing trigger.
Fields specified with this resource replace existing fields. Trigger names cannot be changed.
Fields
Field | Required? | Value | Description |
---|---|---|---|
description |
No | String | Additional text to further describe the trigger. |
tags |
No | Array | A list of arbitrary terms to associate with the trigger. |
type |
Yes | Object | The trigger source, one of For more information about specifying a |
Status codes
- 200 (OK: trigger was updated)
- 400 (Bad Request: invalid trigger)
- 404 (Not Found: trigger doesn't exist)
Example
cat << EOF | curl https://YOUR-API-ENDPOINT/v1/notification/triggers/YOUR-TRIGGER-NAME\
-H "zenoss-api-key: YOUR-API-KEY" -X PUT -s -d @-
{
"description": "Match events with 'updated example' in their summary.",
"type": {
"event": {
"query": {
"clause": {
"contains": {
"field": "summary",
"value": "updated example"
}
}
}
}
}
}
EOF
{
"trigger": {
"name": "YOUR-TRIGGER-NAME",
"description": "Match events with 'updated example' in their summary.",
"type": {
"event": {
"query": {
"clause": {
"contains": {
"field": "summary",
"value": "updated example"
}
}
}
}
}
}
}
DELETE /v1/notification/triggers/{name}
Deletes a trigger.
Use the get multiple triggers resource to get trigger names.
Status codes
- 200 (OK: trigger was deleted)
- 404 (Not Found: trigger doesn't exist)
- 412 (Precondition Failed: trigger is used in at least one rule)
Example
curl https://YOUR-API-ENDPOINT/v1/notification/triggers/YOUR-TRIGGER-NAME \
-H "zenoss-api-key: YOUR-API-KEY" -X DELETE -s
{}