Zabbix Documentation 2.0

3.04.04.2 (current)In development:4.4 (devel)Unsupported:1.82.02.22.43.23.4

User Tools

Site Tools


manual:appendix:api:event:get

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:appendix:api:event:get [2012/05/18 11:26]
jelisejev [Parameters]
manual:appendix:api:event:get [2019/01/28 14:49] (current)
sasha <code js> => <code java>
Line 1: Line 1:
-===== get() ===== +===== event.get =====
-Available since version: **1.8**\\ +
-This function allows you to retrieve ​event details based on filtering options. +
-All parameters are optional. If parameter is set in query, this option is considered as being ON, except if parameter is equal to NULL. +
-====Parameters==== +
-^Parameter^Type^Description^Details^ +
-|**nodeids**|//​array//​|Node IDs | | +
-|**groupids**|//​array//​|HostGroup IDs | | +
-|**hostids**|//​array//​|Host IDs | | +
-|**triggerids**|//​array//​|Trigger IDs | | +
-|**eventids**|//​array//​|Event IDs | | +
-|**editable**|//​integer//​|only with read-write permission. Ignored for SuperAdmins | | +
-|**showUnknown**|//​integer//​|Show unknown events | | +
-|**time_from**|//​integer//​|Events since specified date |Unix timestamp | +
-|**time_till**|//​integer//​|Events till specified date |Unix timestamp | +
-|**eventid_from**|//​integer//​|Events with IDs greater or equal than specified | | +
-|**eventid_till**|//​integer//​|Events with IDs less or equal than specified | | +
-|**output**|//​string//​|Output options | Values: shorten, refer, extend| +
-|**selectHosts**|//​string//​|Select hosts| Values: shorten, refer, extend| +
-|**selectItems**|//​string//​|Select items| Values: shorten, refer, extend| +
-|**selectTriggers**|//​string//​|Select event triggers| Values: shorten, refer, extend| +
-|**select_alerts**|//​string//​|Select alerts| Values: shorten, refer, extend| +
-|**select_acknowledges**|//​string//​|Select acknowledges| Values: shorten, refer, extend| +
-|**countOutput**|//​integer//​|Count hosts, returned number of found hosts | | +
-|**groupCount**|//​integer//​|Return the number of results grouped by IDs| | +
-|**preservekeys**|//​integer//​|Return hash instead of array |Keys of hash are object IDs | +
-|**sortfield**|//​string/​array//​|Sort by event field(s) |Values: eventid, object, clock | +
-|**sortorder**|//​string/​array//​|Sort order | Values: ASC, DESC| +
-|**limit**|//​int//​|max number of host objects to return | |+
  
-====Returns==== +==== Description ​====
-^Parameter^Description^ +
-|**result**|Operation successful. Result will contain array of Event objects.| +
-|**error**|In case of any errors|+
  
-==== Example ====+''​integer/​array event.get(object **parameters**)''​
  
-Get last 10 events for specified period+The method allows to retrieve ​events ​according to the given parameters. 
-<​code ​js>+ 
 +==== Parameters ==== 
 + 
 +''​(object)''​ Parameters defining the desired output. 
 + 
 +The method supports the following parameters. 
 + 
 +^ Parameter ^ Type ^ Description ^ 
 +| eventids | string/​array | Return only events with the given IDs. | 
 +| groupids | string/​array | Return only events created by triggers that belong to the given host groups. | 
 +| hostids | string/​array | Return only events created by triggers that belong to the given hosts. | 
 +| triggerids | string/​array | Return only events that have been created by the given triggers. | 
 +| object | integer | Return only events created by objects of the given type. \\ \\ Refer to the  [[definitions#​event|event object page]] ​for a list of supported object types. | 
 +| source | integer | Return only events with the given type. \\ \\ Refer to the  [[definitions#​event|event object page]] for a list of supported event types. | 
 +^ ||| 
 +| acknowledged | boolean | If set to ''​true''​ return only acknowledged events. | 
 +| value | integer/​array | Return only events with the given values. | 
 +| 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. | 
 +| eventid_from | string | Return only events with IDs greater or equal to the given ID. | 
 +| eventid_till | string | Return only events with IDs less or equal to the given ID. | 
 +^ ||| 
 +| selectHosts | query | Return hosts containing the trigger that created the event in the ''​hosts''​ property. \\ \\ Does not support ''​shorten''​ or arrays of properties. | 
 +| selectItems | query | Return items contained in the trigger that created the event in the ''​items''​ property. \\ \\ Does not support ''​shorten''​ or arrays of properties. | 
 +| selectTriggers | query | Return the trigger that created the event as an array in the ''​triggers''​ property. \\ \\ Does not support ''​shorten''​ or arrays of properties. | 
 +| select_alerts | query | Return alerts generated by the event in the ''​alerts''​ property. Alerts are sorted in reverse chronological order. \\ \\ Does not support ''​shorten''​ or arrays of properties. | 
 +| 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; \\ ''​userid''​ - ''​(string)''​ ID of the user that acknowledged the event; \\ ''​eventid''​ - ''​(string)''​ ID of the acknowledged event; \\ ''​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. \\ \\ Supports ''​count'';​ does not support ''​shorten''​ or arrays of properties. | 
 +^ ||| 
 +| sortfield | string/​array | Sort the result by the given properties. \\ \\ Possible values are: ''​eventid'',​ ''​object''​ and ''​objectid''​. ​ | 
 +| countOutput |flag|These parameters being common for all ''​get''​ methods are described in detail on the [[manual:​appendix:​api:​generic#​common_get_method_parameters|Generic Zabbix API information]] page.  | 
 +| editable |boolean|:::​| 
 +| excludeSearch |flag|:::​| 
 +| filter | object |:::| 
 +| limit |integer|:::​| 
 +| nodeids |string/​array|:::​| 
 +| 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. 
 + 
 +==== Examples ==== 
 + 
 +=== Retrieving trigger events === 
 + 
 +Retrieve the latest events from trigger "​13926."​ 
 + 
 +Request
 +<​code ​java>
 { {
-"​jsonrpc":"​2.0",​ +    ​"​jsonrpc":​ "​2.0",​ 
-"​method":"​event.get",​ +    "​method":​ "​event.get",​ 
-"​params":​{ +    "​params":​ { 
- "time_from":"​1284910040", +        "output": "extend", 
- "time_till": "1284991200", +        "select_acknowledges": "extend", 
- "output": "extend", +        "triggerids": "13926", 
- "​sortfield":​ "clock", +        "​sortfield":​ "eventid", 
- "​sortorder":​ "desc"+        "​sortorder":​ "DESC
- "​limit":​ 5 +    }, 
-}, +    "​auth":​ "038e1d7b1735c6a5436ee9eae095879e", 
-"​auth":"​6f38cddc44cfbb6c1bd186f9a220b5a0", +    "​id": ​1
-"​id":​2+
 } }
 </​code>​ </​code>​
  
-Retrieved events details:+Response: 
 +<code java> 
 +
 +    "​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",​ 
 +            "​value_changed":​ "​1"​ 
 +        }, 
 +        { 
 +            "​acknowledges":​ [], 
 +            "​eventid":​ "​9671",​ 
 +            "​source":​ "​0",​ 
 +            "​object":​ "​0",​ 
 +            "​objectid":​ "​13926",​ 
 +            "​clock":​ "​1347970347",​ 
 +            "​value":​ "​2",​ 
 +            "​acknowledged":​ "​0",​ 
 +            "​ns":​ "​0",​ 
 +            "​value_changed":​ "​0"​ 
 +        } 
 +    ], 
 +    "​id":​ 1 
 +
 +</​code>​
  
-<​code ​js>+=== Retrieving events by time period === 
 + 
 +Retrieve all events that have been created between October 9 and 10, 2012, in reverse chronological order. 
 + 
 +Request: 
 +<​code ​java>
 { {
-"​jsonrpc":"​2.0",​ +    ​"​jsonrpc":​ "​2.0",​ 
-"result":[{ +    "method": "event.get", 
- "eventid":"​100100000884382", +    "params": { 
- "source":"​0",​ +        "output": "extend", 
- "​object":"​0",​ +        "time_from": "1349797228", 
- "​objectid":"​100100000064507",​ +        "time_till": "1350661228", 
- "​clock":"​1284910089",​ +        "sortfield": "​eventid",​ 
- "​value":"​1",​ +        "sortorder": "desc
- "​acknowledged":"​0",​ +    }, 
- "​ns":"​0",​ +    "auth": "038e1d7b1735c6a5436ee9eae095879e", 
- "​value_changed":"​1"​ +    "id": 1
-},+
- "eventid":"​100100000884383", +
- "source":"​0", +
- "object":"​0", +
- "objectid":"​100100000064661",​ +
- "​clock":"​1284910089",​ +
- "​value":"​1",​ +
- "​acknowledged":"​0",​ +
- "​ns":"​0",​ +
- "​value_changed":"​1"​ +
-},{ +
- "​eventid":"​100100000884385", +
- "source":"​0", +
- "​object":"​0",​ +
- "​objectid":"​100100000064661",​ +
- "​clock":"​1284910118",​ +
- "​value":"​0",​ +
- "​acknowledged":"​0",​ +
- "​ns":"​0",​ +
- "​value_changed":"​1+
-},{ +
- "eventid":"​100100000884384", +
- "source":"​0",​ +
- "​object":"​0",​ +
- "​objectid":"​100100000064507",​ +
- "​clock":"​1284910119",​ +
- "​value":"​0",​ +
- "​acknowledged":"​0",​ +
- "​ns":"​0",​ +
- "​value_changed":"​1+
-},{ +
- "​eventid":"​100100000884386",​ +
- "​source":"​0",​ +
- "​object":"​0",​ +
- "​objectid":"​100100000064661",​ +
- "​clock":"​1284910176",​ +
- "​value":"​1",​ +
- "​acknowledged":"​0",​ +
- "​ns":"​0",​ +
- "​value_changed":"​1"​ +
-}], +
-"​id":​2+
 } }
 </​code>​ </​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ [
 +        {
 +            "​eventid":​ "​20616",​
 +            "​source":​ "​0",​
 +            "​object":​ "​0",​
 +            "​objectid":​ "​14282",​
 +            "​clock":​ "​1350477814",​
 +            "​value":​ "​2",​
 +            "​acknowledged":​ "​0",​
 +            "​ns":​ "​0",​
 +            "​value_changed":​ "​0"​
 +        },
 +        {
 +            "​eventid":​ "​20617",​
 +            "​source":​ "​0",​
 +            "​object":​ "​0",​
 +            "​objectid":​ "​14283",​
 +            "​clock":​ "​1350477814",​
 +            "​value":​ "​2",​
 +            "​acknowledged":​ "​0",​
 +            "​ns":​ "​0",​
 +            "​value_changed":​ "​0"​
 +        },
 +        {
 +            "​eventid":​ "​20618",​
 +            "​source":​ "​0",​
 +            "​object":​ "​0",​
 +            "​objectid":​ "​14284",​
 +            "​clock":​ "​1350477815",​
 +            "​value":​ "​2",​
 +            "​acknowledged":​ "​0",​
 +            "​ns":​ "​0",​
 +            "​value_changed":​ "​0"​
 +        }
 +    ],
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +==== See also ====
 +
 +  * [[manual:​appendix:​api:​alert:​definitions|Alert]]
 +  * [[manual:​appendix:​api:​item:​definitions|Item]]
 +  * [[manual:​appendix:​api:​host:​definitions|Host]]
 +  * [[manual:​appendix:​api:​trigger:​definitions|Trigger]]
 +
 +==== Source ====
 +
 +CEvent::​get() in //​frontends/​php/​api/​classes/​CEvent.php//​.