Sidebar

manual:appendix:api:alert:get

alert.get

Description

integer/array alert.get(object parameters)

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

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

Parameter Type Description
alertids string/array Return only alerts with the given IDs.
actionids string/array Return only alerts generated by the given actions.
eventids string/array Return only alerts generated by the given events.
groupids string/array Return only alerts generated by objects from the given host groups.
hostids string/array Return only alerts generated by objects from the given hosts.
mediatypeids string/array Return only message alerts that used the given media types.
triggerids string/array Return only alerts generated by the given triggers.
userids string/array Return only message alerts that were sent to the given users.
time_from timestamp Return only alerts that have been generated after the given time.
time_till timestamp Return only alerts that have been generated before the given time.
selectHosts query Return the hosts that triggered the action operation in the hosts property.

Does not support shorten or arrays of properties.
selectMediatypes query Return the media type that was used for the message alert as an array in the mediatypes property.

Does not support shorten or arrays of properties.
selectUsers query Return the user that the message was addressed to as an array in the users property.

Does not support shorten or arrays of properties.
sortfield string/array Sort the result by the given properties.

Possible values are: alertid, clock, eventid and status.
countOutput flagThese parameters being common for all get methods are described in detail on the 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

Retrieve alerts by action ID

Retrieve all alerts generated by action “3”.

Request:

{
    "jsonrpc": "2.0",
    "method": "alert.get",
    "params": {
        "output": "extend",
        "actionids": "3"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "alertid": "1",
            "actionid": "3",
            "eventid": "21243",
            "userid": "1",
            "clock": "1362128008",
            "mediatypeid": "1",
            "sendto": "[email protected]",
            "subject": "PROBLEM: Zabbix agent on Linux server is unreachable for 5 minutes: ",
            "message": "Trigger: Zabbix agent on Linux server is unreachable for 5 minutes: \nTrigger status: PROBLEM\nTrigger severity: Not classified",
            "status": "0",
            "retries": "3",
            "error": "",
            "esc_step": "1",
            "alerttype": "0"
        }
    ],
    "id": 1
}

See also

Source

CAlert::get() in frontends/php/api/classes/CAlert.php.