# event.get

### Description

`integer/array event.get(object parameters)`

The method allows to retrieve events according to the given parameters.

::: noteimportant
Since Zabbix 2.2.6 this method may return events
of a deleted entity if these events have not been removed by the
housekeeper yet.
:::

### 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 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.|
|object|integer|Return only events created by objects of the given type.<br><br>Refer to the [event object page](object#event) for a list of supported object types.<br><br>Default: 0 - trigger.|
|acknowledged|boolean|If set to `true` return only acknowledged events.|
|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.|
|source|integer|Return only events with the given type.<br><br>Refer to the [event object page](object#event) for a list of supported event types.<br><br>Default: 0 - trigger events.|
|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.|
|selectRelatedObject|query|Return the object that created the event in the `relatedObject` property. The type of object returned depends on the event type.|
|select\_alerts|query|Return alerts generated by the event in the `alerts` property. Alerts are sorted in reverse chronological order.|
|select\_acknowledges|query|Return event's acknowledges in the `acknowledges` property. Acknowledges are sorted in reverse chronological order.<br><br>The event acknowledgement object has the following properties:<br>`acknowledgeid` - `(string)` acknowledgement's ID;<br>`userid` - `(string)` ID of the user that acknowledged the event;<br>`eventid` - `(string)` ID of the acknowledged event;<br>`clock` - `(timestamp)` time when the event was acknowledged;<br>`message` - `(string)` text of the acknowledgement message;<br>`alias` - `(string)` alias of the user that acknowledged the event;<br>`name` - `(string)` name of the user that acknowledged the event;<br>`surname` - `(string)` surname of the user that acknowledged the event.<br><br>Supports `count`.|
|sortfield|string/array|Sort the result by the given properties.<br><br>Possible values are: `eventid`, `objectid`, `clock` and ~~`object`~~ (deprecated).|
|countOutput|flag|These parameters being common for all `get` methods are described in detail in the [reference commentary](/manual/api/reference_commentary#common_get_method_parameters) 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|^|
|~~selectItems~~<br>(deprecated)|query|Return items contained in the trigger that created the event in the `items` property.|
|~~selectTriggers~~<br>(deprecated)|query|Return the trigger that created the event as an array in the `triggers` property.|
|~~triggerids~~<br>(deprecated)|string/array|Return only events that have been created by the given triggers.|

### 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:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "event.get",
    "params": {
        "output": "extend",
        "select_acknowledges": "extend",
        "objectids": "13926",
        "sortfield": ["clock", "eventid"],
        "sortorder": "DESC"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": [
        {
            "acknowledges": [
                {
                    "acknowledgeid": "1",
                    "userid": "1",
                    "eventid": "9695",
                    "clock": "1350640590",
                    "message": "Problem resolved.\n\r----[BULK ACKNOWLEDGE]----",
                    "alias": "Admin",
                    "name": "Zabbix",
                    "surname": "Administrator"
                }
            ],
            "eventid": "9695",
            "source": "0",
            "object": "0",
            "objectid": "13926",
            "clock": "1347970410",
            "value": "1",
            "acknowledged": "1",
            "ns": "413316245"
        },
        {
            "acknowledges": [],
            "eventid": "9671",
            "source": "0",
            "object": "0",
            "objectid": "13926",
            "clock": "1347970347",
            "value": "0",
            "acknowledged": "0",
            "ns": "0"
        }
    ],
    "id": 1
}
```

#### Retrieving events by time period

Retrieve all events that have been created between October 9 and 10,
2012, in reverse chronological order.

Request:

``` {.java}
{
    "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:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": [
        {
            "eventid": "20616",
            "source": "0",
            "object": "0",
            "objectid": "14282",
            "clock": "1350477814",
            "value": "1",
            "acknowledged": "0",
            "ns": "0"
        },
        {
            "eventid": "20617",
            "source": "0",
            "object": "0",
            "objectid": "14283",
            "clock": "1350477814",
            "value": "0",
            "acknowledged": "0",
            "ns": "0"
        },
        {
            "eventid": "20618",
            "source": "0",
            "object": "0",
            "objectid": "14284",
            "clock": "1350477815",
            "value": "1",
            "acknowledged": "0",
            "ns": "0"
        }
    ],
    "id": 1
}
```

### See also

-   [Alert](/manual/api/reference/alert/object)
-   [Item](/manual/api/reference/item/object)
-   [Host](/manual/api/reference/host/object)
-   [LLD rule](/manual/api/reference/discoveryrule/object#lld_rule)
-   [Trigger](/manual/api/reference/trigger/object)

### Source

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