Skip to main 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

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

Field

Type

Required

Description

name

string

Yes

A unique, short identifier for the trigger.

Once created, this value cannot be changed.

description

string

No

Additional text to further describe the trigger.

tags

array

No

A list of arbitrary terms to associate with the trigger.

type

object

Yes

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

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

Response codes

Code

Description

200

Success. The trigger was created.

400

Bad request. The request body is missing, malformed, or contains invalid values.

401

Unauthorized. The API key is missing or invalid.

409

Conflict. A trigger with the same name already exists.

500

Internal server error. An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support.

Example

Request 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"
          }
        }
      }
    }
  }
}'

Response 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 one trigger.

Response fields

Responses may include the following fields.

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.

Response codes

Code

Description

200

Success. The trigger exists and is returned in the response body.

401

Unauthorized. The API key is missing or invalid.

404

Not found. The specified trigger does not exist.

500

Internal server error. An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support.

Example

Request example

curl https://YOUR-API-ENDPOINT/v1/notification/triggers/YOUR-TRIGGER-NAME \
  -H "zenoss-api-key: YOUR-API-KEY" -X GET -s

Response example

{
  "trigger": {
    "name": "YOUR-TRIGGER-NAME",
    "description": "Match events with 'example' in their summary.",
    "type": {
      "event": {
        "query": {
          "clause": {
            "contains": {
              "field": "summary",
              "value": "example"
            }
          }
        }
      }
    }
  }
}

Get all triggers or triggers that match a query. Requests with no queries will return all triggers.

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.

Field

Description

name

The unique identifier of the trigger.

description

The text that describes the trigger.

type

The trigger source type.

ruleNames

The names of rules that use the trigger.

tags

The terms associated with the trigger.

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

Response fields

Responses may include the following 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.

Response codes

Code

Description

200

Success. Matching triggers are returned in the response body. Returns an empty array if no triggers match the query.

401

Unauthorized. The API key is missing or invalid.

500

Internal server error. An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support.

All triggers example

Request example

curl https://YOUR-API-ENDPOINT/v1/notification/triggers \
  -H "zenoss-api-key: YOUR-API-KEY" -X GET -s

Response example

{
  "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"
    }
  ],
  "totalCount": "3"
}

Query string example

Request example

curl "https://YOUR-API-ENDPOINT/v1/notification/triggers?ruleNames=test-rule-2" \
  -H "zenoss-api-key: YOUR-API-KEY" -X GET -s

Response example

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

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.

Response codes

Code

Description

200

Success. The trigger was updated.

400

Bad request. The request body is missing, malformed, or contains invalid values.

401

Unauthorized. The API key is missing or invalid.

404

Not found. The specified trigger does not exist.

500

Internal server error. An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support.

Example

Request example

curl https://YOUR-API-ENDPOINT/v1/notification/triggers/YOUR-TRIGGER-NAME \
  -H "content-type: application/json" \
  -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"
          }
        }
      }
    }
  }
}'

Response example

{
  "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 a trigger.

Use the get multiple triggers resource to get trigger names.

Response codes

Code

Description

200

Success. The trigger was deleted.

401

Unauthorized. The API key is missing or invalid.

404

Not found. The specified trigger does not exist.

412

Precondition failed. The trigger is used in at least one rule and cannot be deleted.

500

Internal server error. An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support.

Example

Request example

curl https://YOUR-API-ENDPOINT/v1/notification/triggers/YOUR-TRIGGER-NAME \
  -H "zenoss-api-key: YOUR-API-KEY" -X DELETE -s

Response example

{}