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:
- {
- "jsonrpc": "2.0",
- "method": "event.get",
- "params": {
- "output": "extend",
- "select_acknowledges": "extend",
- "objectids": "13926",
- "sortfield": ["clock", "eventid"],
- "sortorder": "DESC"
- },
- "auth": "038e1d7b1735c6a5436ee9eae095879e",
- "id": 1
- }
Response:
- {
- "jsonrpc": "2.0",
- "result": [
- {
- "acknowledges": [
- {
- "acknowledgeid": "1",
- "userid": "1",
- "eventid": "9695",
- "clock": "1350640590",
- "message": "Problem resolved.\n\r----[BULK ACKNOWLEDGE]----",
- "alias": "Admin"
- }
- ],
- "eventid": "9695",
- "source": "0",
- "object": "0",
- "objectid": "13926",
- "clock": "1347970410",
- "value": "1",
- "acknowledged": "1",
- "ns": "413316245",
- "r_eventid": "0",
- "c_eventid": "0",
- "correlationid": "0",
- "userid": "0",
- "tags": [
- {
- "tag": "service",
- "value": "mysqld"
- },
- {
- "tag": "error",
- "value": ""
- }
- ]
- },
- {
- "acknowledges": [],
- "eventid": "9671",
- "source": "0",
- "object": "0",
- "objectid": "13926",
- "clock": "1347970347",
- "value": "0",
- "acknowledged": "0",
- "ns": "0",
- "r_eventid": "0",
- "c_eventid": "0",
- "correlationid": "0",
- "userid": "0",
- "tags": []
- }
- ],
- "id": 1
- }
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:
- {
- "jsonrpc": "2.0",
- "method": "event.get",
- "params": {
- "output": "extend",
- "time_from": "1349797228",
- "time_till": "1350661228",
- "sortfield": ["clock", "eventid"],
- "sortorder": "desc"
- },
- "auth": "038e1d7b1735c6a5436ee9eae095879e",
- "id": 1
- }
Response:
- {
- "jsonrpc": "2.0",
- "result": [
- {
- "eventid": "20616",
- "source": "0",
- "object": "0",
- "objectid": "14282",
- "clock": "1350477814",
- "value": "1",
- "acknowledged": "0",
- "ns": "0",
- "r_eventid": "0",
- "c_eventid": "0",
- "correlationid": "0",
- "userid": "0"
- },
- {
- "eventid": "20617",
- "source": "0",
- "object": "0",
- "objectid": "14283",
- "clock": "1350477814",
- "value": "0",
- "acknowledged": "0",
- "ns": "0",
- "r_eventid": "0",
- "c_eventid": "0",
- "correlationid": "0",
- "userid": "0"
- },
- {
- "eventid": "20618",
- "source": "0",
- "object": "0",
- "objectid": "14284",
- "clock": "1350477815",
- "value": "1",
- "acknowledged": "0",
- "ns": "0",
- "r_eventid": "0",
- "c_eventid": "0",
- "correlationid": "0",
- "userid": "0"
- }
- ],
- "id": 1
- }
See also 参见
Source 来源
CEvent::get() in frontends/php/include/classes/api/services/CEvent.php.