event.get

Description

描述

integer/array event.get(object **parameters**) 整数/数组 event.get(object **parameters**)

The method allows to retrieve events according to the given parameters. 此方法用于根据给定参数来获取事件

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.
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.
tagsobjectReturn 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.
valueinteger/arrayReturn only events with the given values.
selectHostsqueryReturn hosts containing the object that created the event in the hosts property. Supported only for events generated by triggers, items or LLD rules.
selectRelatedObjectqueryReturn the object that created the event in the relatedObject property. The type of object returned depends on the event type.
select_alertsqueryReturn alerts generated by the event in the alerts property. Alerts are sorted in reverse chronological order.
select_acknowledgesqueryReturn event’s updates in the acknowledges property. Event updates are sorted in reverse chronological order.

The event update object has the following properties:
acknowledgeid - (string) acknowledgement’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 event tags in tags property.
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
参数类型描述
eventidsstring/array仅返回具有给定ID的事件.
groupidsstring/array仅返回由属于给定主机组的对象创建的事件.
hostidsstring/array仅返回由属于给定主机的对象创建的事件。.
objectidsstring/array仅返回由给定对象创建的事件.
applicationidsstring/array仅返回属于给定应用程序的对象创建的事件。仅当对象为触发器或监控项时才适用。
sourceinteger仅返回给定类型的事件.

有关支持的事件类型的列表,请参阅事件对象页面.

默认值: 0 - 触发器事件.
objectinteger仅返回由给定类型的对象创建的事件.

有关支持的对象类型的列表,请参阅事件对象页面.

默认值: 0 - 触发器.
acknowledgedboolean如果设置为“true”,则只返回已被确认的事件.
severitiesinteger/array仅返回符合给定严重程度的事件。仅当对象为触发器时才适用.
evaltypeinteger标签搜索的规则.

可能值:
0 - (默认) 与/或;
2 - 或.
tagsobject仅返回具有给定标签的事件. 按标签进行完全匹配;按值搜索时,不区分大小写.
Format: [{“tag”: “<tag>”, “value”: “<value>”, “operator”: “<operator>”}, …].
一个空数组会返回所有事件.

可能的操作类型:
0 - (默认) 相似(like);
1 - 相等(equal).
eventid_fromstring仅返回ID大于或等于给定ID的事件.
eventid_tillstring仅返回ID小于或等于给定ID的事件.
time_fromtimestamp仅返回在给定时间时或之后创建的事件.
time_tilltimestamp仅返回在给定时间时或之前创建的事件.
valueinteger/array仅返回具有给定值的事件.
selectHostsquery主机 属性下,返回包含创建该事件的对象的主机. 仅支持由触发器、监控项、低级别发现规则生成的事件.
selectRelatedObjectquery相关对象(relatedObject) 属性下,返回创建该事件的对象. 返回的对象类型会依赖于该事件的类型.
select_alertsquery告警 属性下,返回由该事件生成的告警.告警是按反向时间顺序进行排序
select_acknowledgesquery确认 属性下,返回事件的更新. 事件的更新是按反向时间顺序进行排序.

事件更新对象具有以下属性:
acknowledgeid - (string) 确认的ID;
userid - (string) 更新事件的用户的ID;
eventid - (string) 被更新事件的ID;
clock - (timestamp) 事件的更新时间;
message - (string) 消息文本;
action - (integer) 已执行的更新操作,参考event.acknowledge;
old_severity - (integer) event severity before this update action更新操作之前的事件的严重等级;
new_severity - (integer) 更新操作之后的事件的严重等级;
alias - (string) alias of the user that updated the event更新该事件的用户的别名;
name - (string) 更新该事件的用户的名称;
surname - (string) 更新该事件的用户的姓氏.

支持 计数(count).
selectTagsquery标签 属性下,返回事件的标签.
sortfieldstring/array根据给定属性,对结果进行排序.

可能值: eventid, objectid 以及 clock.
countOutputboolean以下参数为get方法通常参数,在参考注释有详细说明.
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.

(整数/数组) 返回:

  • 一个数组对象;

  • 如果使用了 countOutput 参数,返回获取的对象的数量.

Examples

例子

Retrieving trigger events

获取触发器事件

Retrieve the latest events from trigger “13926.” 从触发器“13926”中获取最新事件

Request: 请求:

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

Response: 响应:

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

Retrieving events by time period

按时间段获取事件

Retrieve all events that have been created between October 9 and 10, 2012, in reverse chronological order. 在2012-10-9至2012-10-10时间段内,以逆时间顺序获取所有已被创建的事件。

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. },
  20. {
  21. "eventid": "20617",
  22. "source": "0",
  23. "object": "0",
  24. "objectid": "14283",
  25. "clock": "1350477814",
  26. "value": "0",
  27. "acknowledged": "0",
  28. "ns": "0",
  29. "name": "Zabbix trapper processes more than 75% busy",
  30. "severity": "3",
  31. "r_eventid": "0",
  32. "c_eventid": "0",
  33. "correlationid": "0",
  34. "userid": "0"
  35. },
  36. {
  37. "eventid": "20618",
  38. "source": "0",
  39. "object": "0",
  40. "objectid": "14284",
  41. "clock": "1350477815",
  42. "value": "1",
  43. "acknowledged": "0",
  44. "ns": "0",
  45. "name": "High ICMP ping loss",
  46. "severity": "3",
  47. "r_eventid": "0",
  48. "c_eventid": "0",
  49. "correlationid": "0",
  50. "userid": "0"
  51. }
  52. ],
  53. "id": 1
  54. }

See also

参考

Source

来源

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