event.get

Description 说明

integer/array 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.该方法支持以下参数。

参数 类型 说明
eventids string/array Return only events with the given IDs. 仅返回具有给定ID的事件
groupids string/array Return only events created by objects that belong to the given host groups.仅返回由属于给定主机组的对象创建的事件。
hostids string/array Return only events created by objects that belong to the given hosts.仅返回由属于给定主机的对象创建的事件。
objectids string/array Return only events created by the given objects.仅返回由给定对象创建的事件。
applicationids string/array Return only events created by objects that belong to the given applications. Applies only if object is trigger or item.仅返回属于给定应用程序的对象创建的事件。仅当对象为触发器或项目时才适用。
source integer Return only events with the given type.只返回给定类型的事件。 Refer to the event object page for a list of supported event types.有关支持的事件类型的列表,请参阅事件对象页面。 Default: 0 - trigger events.默认值:0 - 触发事件。
object integer Return 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.默认值:0 - 触发。
acknowledged boolean If set to true return only acknowledged events. 如果设置为“true”,则只返回确认的事件。
severities integer/array Return only events with given trigger severities. Applies only if object is trigger.只返回给定触发严重程度的事件。仅当对象被触发时才适用。
tags object Return only events with given tags. Exact match by tag and case-insensitive search by value.只返回给定标签的事件。 按照标签的精确匹配和按值搜索不区分大小写的搜索。Format: [{"tag": "<tag>", "value": "<value>"}, …].格式: [{"tag": "<tag>", "value": "<value>"}, …].An empty array returns all events.一个空数组返回所有事件。
eventid_from string Return only events with IDs greater or equal to the given ID.只返回ID大于或等于给定ID的事件。
eventid_till string Return only events with IDs less or equal to the given ID. 只返回ID小于或等于给定ID的事件。
time_from timestamp Return only events that have been created after or at the given time. 仅返回在给定时间时或之后创建的事件
time_till timestamp Return only events that have been created before or at the given time. 仅返回在特定时间时或之前创建的事件。
value integer/array Return only events with the given values.仅返回具有给定值的事件。
selectHosts query Return hosts containing the object that created the event in the hosts property. Supported only for events generated by triggers, items or LLD rules.在“hosts”属性中返回包含创建事件的对象的主机。 仅对触发器,项目或LLD规则生成的事件支持。
selectRelatedObject query

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. "objectids": "13926",
  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. "acknowledges": [
  6. {
  7. "acknowledgeid": "1",
  8. "userid": "1",
  9. "eventid": "9695",
  10. "clock": "1350640590",
  11. "message": "Problem resolved.\n\r----[BULK ACKNOWLEDGE]----",
  12. "alias": "Admin"
  13. }
  14. ],
  15. "eventid": "9695",
  16. "source": "0",
  17. "object": "0",
  18. "objectid": "13926",
  19. "clock": "1347970410",
  20. "value": "1",
  21. "acknowledged": "1",
  22. "ns": "413316245",
  23. "r_eventid": "0",
  24. "c_eventid": "0",
  25. "correlationid": "0",
  26. "userid": "0",
  27. "tags": [
  28. {
  29. "tag": "service",
  30. "value": "mysqld"
  31. },
  32. {
  33. "tag": "error",
  34. "value": ""
  35. }
  36. ]
  37. },
  38. {
  39. "acknowledges": [],
  40. "eventid": "9671",
  41. "source": "0",
  42. "object": "0",
  43. "objectid": "13926",
  44. "clock": "1347970347",
  45. "value": "0",
  46. "acknowledged": "0",
  47. "ns": "0",
  48. "r_eventid": "0",
  49. "c_eventid": "0",
  50. "correlationid": "0",
  51. "userid": "0",
  52. "tags": []
  53. }
  54. ],
  55. "id": 1
  56. }

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日至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. "r_eventid": "0",
  14. "c_eventid": "0",
  15. "correlationid": "0",
  16. "userid": "0"
  17. },
  18. {
  19. "eventid": "20617",
  20. "source": "0",
  21. "object": "0",
  22. "objectid": "14283",
  23. "clock": "1350477814",
  24. "value": "0",
  25. "acknowledged": "0",
  26. "ns": "0",
  27. "r_eventid": "0",
  28. "c_eventid": "0",
  29. "correlationid": "0",
  30. "userid": "0"
  31. },
  32. {
  33. "eventid": "20618",
  34. "source": "0",
  35. "object": "0",
  36. "objectid": "14284",
  37. "clock": "1350477815",
  38. "value": "1",
  39. "acknowledged": "0",
  40. "ns": "0",
  41. "r_eventid": "0",
  42. "c_eventid": "0",
  43. "correlationid": "0",
  44. "userid": "0"
  45. }
  46. ],
  47. "id": 1
  48. }

See also 参见

Source 来源

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