Skip to content

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

POST /v1/notification/triggers

Create a trigger.

Request template

An abstract preview of a JSON request to create one trigger.

{
  "name": "<name>",
  "description": "<description>",
  "tags": [ "<tag>" ],
  "type": {
    "<type>": {
      "query": { * }
    }
  }
}

Request fields

name (string, required)

A unique, short identifier for the trigger.

Once created, the value of a name field cannot be changed.

description (string, optional)
Additional text to further describe the trigger.
tags (array, optional)
A list of arbitrary terms to associate with the trigger.
type (object, required)

The trigger source; anomaly, event, or metricThreshold (metric).

For more information about specifying a type object, see Trigger queries.

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}

Get one trigger.

Response fields

Responses may include the following fields.

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]

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

Query fields

The following query fields are supported. Each field may be used only once in a query. Searches determine whether the destination contains the specified value.

  • name
  • description
  • type
  • ruleNames
  • tags

For more information about query fields, see the create a trigger resource.

Response fields

Responses may include the following fields.

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}

Update an existing trigger.

Fields specified with this resource replace existing fields. Trigger names cannot be changed.

Request fields

Update requests use the same fields as create requests.

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}

Delete 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
{}