alert.get

描述

整数/数组 alert.get(object parameters)

该方式允许根据给定的参数检索警报.

参数

(object) 定义所需输出的参数。

该方法支持以下参数.

参数 类描述
alertidsstring/array只返回给定 ID 的 alerts。
actionidsstring/array只返回给定 actions 生成的 alerts。
eventidsstring/array只返回给定事件生成的 alerts。
groupidsstring/array只返回来自指定主机组的对象生成的 alerts。
hostidsstring/array只返回来自指定主机的对象生成的 alerts。
mediatypeidsstring/array只返回用于指定报警媒介类型的消息警报。
objectidsstring/array只返回指定对象生成的 alerts。
useridsstring/array只返回发送给指定用户的消息警报。
eventobjectinteger仅返回与给定类型的对象相关的事件生成的警报。

参考 event “object” property 获取受支持的对象类型列表。

默认值: 0 - trigger.
eventsourceinteger仅返回由给定类型的事件生成的警报。

参考 event “source” property 获取受支持的对象类型列表。

默认值: 0 - trigger events.
time_fromtimestamp仅返回在给定时间后生成的警报。
time_tilltimestamp仅返回在给定时间之前生成的警报。
selectHostsqueryhosts 属性中返回触发 action 操作的主机。
selectMediatypesqueryReturn the media type that was used for the message alert as an array in the mediatypes property.
selectUsersqueryReturn the user that the message was addressed to as an array in the users property.
sortfieldstring/arraySort the result by the given properties.

Possible values are: alertid, clock, eventid and status.
countOutputbooleanThese parameters being common for all get methods are described in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

范例

通过动作 ID 检索警报

Retrieve all alerts generated by action “3”.

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "alert.get",
  4. "params": {
  5. "output": "extend",
  6. "actionids": "3"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

返回值:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "alertid": "1",
  6. "actionid": "3",
  7. "eventid": "21243",
  8. "userid": "1",
  9. "clock": "1362128008",
  10. "mediatypeid": "1",
  11. "sendto": "[email protected]",
  12. "subject": "PROBLEM: Zabbix agent on Linux server is unreachable for 5 minutes: ",
  13. "message": "Trigger: Zabbix agent on Linux server is unreachable for 5 minutes: \nTrigger status: PROBLEM\nTrigger severity: Not classified",
  14. "status": "0",
  15. "retries": "3",
  16. "error": "",
  17. "esc_step": "1",
  18. "alerttype": "0",
  19. "p_eventid": "0",
  20. "acknowledgeid": "0"
  21. }
  22. ],
  23. "id": 1
  24. }

参见

Source

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

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.

ParameterTypeDescription
alertidsstring/arrayReturn only alerts with the given IDs.
actionidsstring/arrayReturn only alerts generated by the given actions.
eventidsstring/arrayReturn only alerts generated by the given events.
groupidsstring/arrayReturn only alerts generated by objects from the given host groups.
hostidsstring/arrayReturn only alerts generated by objects from the given hosts.
mediatypeidsstring/arrayReturn only message alerts that used the given media types.
objectidsstring/arrayReturn only alerts generated by the given objects
useridsstring/arrayReturn only message alerts that were sent to the given users.
eventobjectintegerReturn only alerts generated by events related to objects of the given type.

Refer to the event “object” property for a list of supported object types.

Default: 0 - trigger.
eventsourceintegerReturn only alerts generated by events of the given type.

Refer to the event “source” property for a list of supported event types.

Default: 0 - trigger events.
time_fromtimestampReturn only alerts that have been generated after the given time.
time_tilltimestampReturn only alerts that have been generated before the given time.
selectHostsqueryReturn the hosts that triggered the action operation in the hosts property.
selectMediatypesqueryReturn the media type that was used for the message alert as an array in the mediatypes property.
selectUsersqueryReturn the user that the message was addressed to as an array in the users property.
sortfieldstring/arraySort the result by the given properties.

Possible values are: alertid, clock, eventid and status.
countOutputbooleanThese parameters being common for all get methods are described in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "alert.get",
  4. "params": {
  5. "output": "extend",
  6. "actionids": "3"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "alertid": "1",
  6. "actionid": "3",
  7. "eventid": "21243",
  8. "userid": "1",
  9. "clock": "1362128008",
  10. "mediatypeid": "1",
  11. "sendto": "[email protected]",
  12. "subject": "PROBLEM: Zabbix agent on Linux server is unreachable for 5 minutes: ",
  13. "message": "Trigger: Zabbix agent on Linux server is unreachable for 5 minutes: \nTrigger status: PROBLEM\nTrigger severity: Not classified",
  14. "status": "0",
  15. "retries": "3",
  16. "error": "",
  17. "esc_step": "1",
  18. "alerttype": "0",
  19. "p_eventid": "0",
  20. "acknowledgeid": "0"
  21. }
  22. ],
  23. "id": 1
  24. }

See also