event.get

Description

integer/array event.get(object **parameters**)

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

This method may return events of a deleted entity if these events have not been removed by the housekeeper yet.

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
eventidsstring/arrayReturn only events with the given IDs.
groupidsstring/arrayReturn only events created by objects that belong to the given host groups.
hostidsstring/arrayReturn only events created by objects that belong to the given hosts.
objectidsstring/arrayReturn only events created by the given objects.
applicationidsstring/arrayReturn only events created by objects that belong to the given applications. Applies only if object is trigger or item.
sourceintegerReturn only events with the given type.

Refer to the event object page for a list of supported event types.

Default: 0 - trigger events.
objectintegerReturn only events created by objects of the given type.

Refer to the event object page for a list of supported object types.

Default: 0 - trigger.
acknowledgedbooleanIf set to true return only acknowledged events.
suppressedbooleantrue - return only suppressed events;
false - return events in the normal state.
severitiesinteger/arrayReturn only events with given event severities. Applies only if object is trigger.
evaltypeintegerRules for tag searching.

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

Possible operator types:
0 - (default) Like;
1 - Equal.
eventid_fromstringReturn only events with IDs greater or equal to the given ID.
eventid_tillstringReturn only events with IDs less or equal to the given ID.
time_fromtimestampReturn only events that have been created after or at the given time.
time_tilltimestampReturn only events that have been created before or at the given time.
problem_time_fromtimestampReturns only events that were in the problem state starting with problem_time_from. Applies only if the source is trigger event and object is trigger. Mandatory if problem_time_till is specified.
problem_time_tilltimestampReturns only events that were in the problem state until problem_time_till. Applies only if the source is trigger event and object is trigger. Mandatory if problem_time_from is specified.
valueinteger/arrayReturn only events with the given values.
selectHostsqueryReturn a hosts property with hosts containing the object that created the event. Supported only for events generated by triggers, items or LLD rules.
selectRelatedObjectqueryReturn a relatedObject property with the object that created the event. The type of object returned depends on the event type.
select_alertsqueryReturn an alerts property with alerts generated by the event. Alerts are sorted in reverse chronological order.
select_acknowledgesqueryReturn an acknowledges property with event updates. Event updates are sorted in reverse chronological order.

The event update object has the following properties:
acknowledgeid - (string) acknowledgment’s ID;
userid - (string) ID of the user that updated the event;
eventid - (string) ID of the updated event;
clock - (timestamp) time when the event was updated;
message - (string) text of the message;
action - (integer) update action that was performed see event.acknowledge;
old_severity - (integer) event severity before this update action;
new_severity - (integer) event severity after this update action;
alias - (string) alias of the user that updated the event;
name - (string) name of the user that updated the event;
surname - (string) surname of the user that updated the event.

Supports count.
selectTagsqueryReturn a tags property with event tags.
selectSuppressionDataqueryReturn a suppression_data property with the list of maintenances:
maintenanceid - (string) ID of the maintenance;
suppress_until - (integer) time until the event is suppressed.
sortfieldstring/arraySort the result by the given properties.

Possible values are: eventid, objectid and clock.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
editableboolean
excludeSearchboolean
filterobject
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 trigger events

Retrieve the latest events from trigger “13926.”

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "event.get",
  4. "params": {
  5. "output": "extend",
  6. "select_acknowledges": "extend",
  7. "selectTags": "extend",
  8. "selectSuppressionData": "extend",
  9. "objectids": "13926",
  10. "sortfield": ["clock", "eventid"],
  11. "sortorder": "DESC"
  12. },
  13. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  14. "id": 1
  15. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "eventid": "9695",
  6. "source": "0",
  7. "object": "0",
  8. "objectid": "13926",
  9. "clock": "1347970410",
  10. "value": "1",
  11. "acknowledged": "1",
  12. "ns": "413316245",
  13. "name": "MySQL is down",
  14. "severity": "5",
  15. "r_eventid": "0",
  16. "c_eventid": "0",
  17. "correlationid": "0",
  18. "userid": "0",
  19. "opdata": "",
  20. "acknowledges": [
  21. {
  22. "acknowledgeid": "1",
  23. "userid": "1",
  24. "eventid": "9695",
  25. "clock": "1350640590",
  26. "message": "Problem resolved.\n\r----[BULK ACKNOWLEDGE]----",
  27. "action": "6",
  28. "old_severity": "0",
  29. "new_severity": "0",
  30. "alias": "Admin",
  31. "name": "Zabbix",
  32. "surname": "Administrator"
  33. }
  34. ],
  35. "suppression_data": [
  36. {
  37. "maintenanceid": "15",
  38. "suppress_until": "1472511600"
  39. }
  40. ],
  41. "suppressed": "1",
  42. "tags": [
  43. {
  44. "tag": "service",
  45. "value": "mysqld"
  46. },
  47. {
  48. "tag": "error",
  49. "value": ""
  50. }
  51. ]
  52. },
  53. {
  54. "eventid": "9671",
  55. "source": "0",
  56. "object": "0",
  57. "objectid": "13926",
  58. "clock": "1347970347",
  59. "value": "0",
  60. "acknowledged": "0",
  61. "ns": "0",
  62. "name": "Unavailable by ICMP ping",
  63. "severity": "4",
  64. "r_eventid": "0",
  65. "c_eventid": "0",
  66. "correlationid": "0",
  67. "userid": "0",
  68. "opdata": "",
  69. "acknowledges": [],
  70. "suppression_data": [],
  71. "suppressed": "0",
  72. "tags": []
  73. }
  74. ],
  75. "id": 1
  76. }

Retrieving events by time period

Retrieve all events that have been created between October 9 and 10, 2012, in reverse chronological order.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "event.get",
  4. "params": {
  5. "output": "extend",
  6. "time_from": "1349797228",
  7. "time_till": "1350661228",
  8. "sortfield": ["clock", "eventid"],
  9. "sortorder": "desc"
  10. },
  11. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  12. "id": 1
  13. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "eventid": "20616",
  6. "source": "0",
  7. "object": "0",
  8. "objectid": "14282",
  9. "clock": "1350477814",
  10. "value": "1",
  11. "acknowledged": "0",
  12. "ns": "0",
  13. "name": "Less than 25% free in the history cache",
  14. "severity": "3",
  15. "r_eventid": "0",
  16. "c_eventid": "0",
  17. "correlationid": "0",
  18. "userid": "0",
  19. "opdata": "",
  20. "suppressed": "0"
  21. },
  22. {
  23. "eventid": "20617",
  24. "source": "0",
  25. "object": "0",
  26. "objectid": "14283",
  27. "clock": "1350477814",
  28. "value": "0",
  29. "acknowledged": "0",
  30. "ns": "0",
  31. "name": "Zabbix trapper processes more than 75% busy",
  32. "severity": "3",
  33. "r_eventid": "0",
  34. "c_eventid": "0",
  35. "correlationid": "0",
  36. "userid": "0",
  37. "opdata": "",
  38. "suppressed": "0"
  39. },
  40. {
  41. "eventid": "20618",
  42. "source": "0",
  43. "object": "0",
  44. "objectid": "14284",
  45. "clock": "1350477815",
  46. "value": "1",
  47. "acknowledged": "0",
  48. "ns": "0",
  49. "name": "High ICMP ping loss",
  50. "severity": "3",
  51. "r_eventid": "0",
  52. "c_eventid": "0",
  53. "correlationid": "0",
  54. "userid": "0",
  55. "opdata": "",
  56. "suppressed": "0"
  57. }
  58. ],
  59. "id": 1
  60. }

See also

Source

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