trigger.get

Description

integer/array trigger.get(object parameters)

The method allows to retrieve triggers according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
triggeridsstring/arrayReturn only triggers with the given IDs.
groupidsstring/arrayReturn only triggers that belong to hosts from the given host groups.
templateidsstring/arrayReturn only triggers that belong to the given templates.
hostidsstring/arrayReturn only triggers that belong to the given hosts.
itemidsstring/arrayReturn only triggers that contain the given items.
functionsstring/arrayReturn only triggers that use the given functions.

Refer to the supported function page for a list of supported functions.
groupstringReturn only triggers that belong to hosts from the host group with the given name.
hoststringReturn only triggers that belong to host with the given name.
inheritedbooleanIf set to true return only triggers inherited from a template.
templatedbooleanIf set to true return only triggers that belong to templates.
dependentbooleanIf set to true return only triggers that have dependencies. If set to false return only triggers that do not have dependencies.
monitoredflagReturn only enabled triggers that belong to monitored hosts and contain only enabled items.
activeflagReturn only enabled triggers that belong to monitored hosts.
maintenancebooleanIf set to true return only enabled triggers that belong to hosts in maintenance.
withUnacknowledgedEventsflagReturn only triggers that have unacknowledged events.
withAcknowledgedEventsflagReturn only triggers with all events acknowledged.
withLastEventUnacknowledgedflagReturn only triggers with the last event unacknowledged.
skipDependentflagSkip triggers in a problem state that are dependent on other triggers. Note that the other triggers are ignored if disabled, have disabled items or disabled item hosts.
lastChangeSincetimestampReturn only triggers that have changed their state after the given time.
lastChangeTilltimestampReturn only triggers that have changed their state before the given time.
only_trueflagReturn only triggers that have recently been in a problem state.
min_severityintegerReturn only triggers with severity greater or equal than the given severity.
evaltypeintegerRules for tag searching.

Possible values:
0 - (default) And/Or;
2 - Or.
tagsarray of objectsReturn only triggers with given tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{“tag”: “<tag>”, “value”: “<value>”, “operator”: “<operator>”}, …].
An empty array returns all triggers.

Possible operator types:
0 - (default) Like;
1 - Equal;
2 - Not like;
3 - Not equal
4 - Exists;
5 - Not exists.
expandCommentflagExpand macros in the trigger description.
expandDescriptionflagExpand macros in the name of the trigger.
expandExpressionflagExpand functions and macros in the trigger expression.
selectGroupsqueryReturn the host groups that the trigger belongs to in the groups property.
selectHostsqueryReturn the hosts that the trigger belongs to in the hosts property.
selectItemsqueryReturn items contained by the trigger in the items property.
selectFunctionsqueryReturn functions used in the trigger in the functions property.

The function objects represent the functions used in the trigger expression and has the following properties:
functionid - (string) ID of the function;
itemid - (string) ID of the item used in the function;
function - (string) name of the function;
parameter - (string) parameter passed to the function. Query parameter is replaced by $ symbol in returned string.
selectDependenciesqueryReturn triggers that the trigger depends on in the dependencies property.
selectDiscoveryRulequeryReturn the low-level discovery rule that created the trigger.
selectLastEventqueryReturn the last significant trigger event in the lastEvent property.
selectTagsqueryReturn the trigger tags in tags property.
selectTriggerDiscoveryqueryReturn the trigger discovery object in the triggerDiscovery property. The trigger discovery objects link the trigger to a trigger prototype from which it was created.

It has the following properties:
parent_triggerid - (string) ID of the trigger prototype from which the trigger has been created.
filterobjectReturn only those results that exactly match the given filter.

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against.

Supports additional filters:
host - technical name of the host that the trigger belongs to;
hostid - ID of the host that the trigger belongs to.
limitSelectsintegerLimits the number of records returned by subselects.

Applies to the following subselects:
selectHosts - results will be sorted by host.
sortfieldstring/arraySort the result by the given properties.

Possible values are: triggerid, description, status, priority, lastchange and hostname.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving data by trigger ID

Retrieve all data and the functions used in trigger “14062”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.get",
  4. "params": {
  5. "triggerids": "14062",
  6. "output": "extend",
  7. "selectFunctions": "extend"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "14062",
  6. "expression": "{13513}<10m",
  7. "description": "{HOST.NAME} has been restarted (uptime < 10m)",
  8. "url": "",
  9. "status": "0",
  10. "value": "0",
  11. "priority": "2",
  12. "lastchange": "0",
  13. "comments": "The host uptime is less than 10 minutes",
  14. "error": "",
  15. "templateid": "10016",
  16. "type": "0",
  17. "state": "0",
  18. "flags": "0",
  19. "recovery_mode": "0",
  20. "recovery_expression": "",
  21. "correlation_mode": "0",
  22. "correlation_tag": "",
  23. "manual_close": "0",
  24. "opdata": "",
  25. "functions": [
  26. {
  27. "functionid": "13513",
  28. "itemid": "24350",
  29. "triggerid": "14062",
  30. "parameter": "$",
  31. "function": "last"
  32. }
  33. ]
  34. }
  35. ],
  36. "id": 1
  37. }

Retrieving triggers in problem state

Retrieve the ID, name and severity of all triggers in problem state and sort them by severity in descending order.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.get",
  4. "params": {
  5. "output": [
  6. "triggerid",
  7. "description",
  8. "priority"
  9. ],
  10. "filter": {
  11. "value": 1
  12. },
  13. "sortfield": "priority",
  14. "sortorder": "DESC"
  15. },
  16. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  17. "id": 1
  18. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "13907",
  6. "description": "Zabbix self-monitoring processes < 100% busy",
  7. "priority": "4"
  8. },
  9. {
  10. "triggerid": "13824",
  11. "description": "Zabbix discoverer processes more than 75% busy",
  12. "priority": "3"
  13. }
  14. ],
  15. "id": 1
  16. }

Retrieving a specific trigger with tags

Retrieve a specific trigger with tags.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.get",
  4. "params": {
  5. "output": [
  6. "triggerid",
  7. "description"
  8. ],
  9. "selectTags": "extend",
  10. "triggerids": [
  11. "17578"
  12. ]
  13. },
  14. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  15. "id": 1
  16. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "17370",
  6. "description": "Service status",
  7. "tags": [
  8. {
  9. "tag": "service",
  10. "value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
  11. },
  12. {
  13. "tag": "error",
  14. "value": ""
  15. }
  16. ]
  17. }
  18. ],
  19. "id": 1
  20. }

See also

Source

CTrigger::get() in ui/include/classes/api/services/CTrigger.php.