Sidebar

2022 Zabbix中国峰会
2022 Zabbix中国峰会

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 Return the object that created the event in the relatedObject property. The type of object returned depends on the event type.返回在''relatedObject'属性中创建事件的对象。返回的对象类型取决于事件类型。
select_alerts query Return alerts generated by the event in the alerts property. Alerts are sorted in reverse chronological order.在“alert”属性中返回事件生成的警报。警报按相反的时间顺序排序。
select_acknowledges query Return event's acknowledges in the acknowledges property. Acknowledges are sorted in reverse chronological order. 返回“确认”属性中的事件确认,确认按相反的时间顺序排序。

The event acknowledgement object has the following properties:事件确认对象具有以下属性:
acknowledgeid - (string) acknowledgement's ID;确认的ID;
userid - (string) ID of the user that acknowledged the event;确认事件的用户的ID;
eventid - (string) ID of the acknowledged event; 确认事件的ID;
clock - (timestamp) time when the event was acknowledged;事件确认的时间;
message - (string) text of the acknowledgement message;确认消息的文本;
alias - (string) alias of the user that acknowledged the event;确认事件的用户的别名;
name - (string) name of the user that acknowledged the event; 确认事件的用户的名称;
surname - (string) surname of the user that acknowledged the event. 确认事件的用户的姓氏。

Supports count.
selectTags query Return event tags in tags property. 在“标签”属性中返回事件标记
sortfield string/array Sort the result by the given properties.按照给定的属性对结果进行排序。

Possible values are: eventid, objectid and clock.可能的值为:eventidobjectidclock
countOutput flag These parameters being common for all get methods are described in detail in the reference commentary page. 这些参数对于所有的“获取”方法是常见的,在参考评论页中有详细描述。
editable boolean
excludeSearch flag
filter object
limit integer
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

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:

{
           "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.