integer/array event.get(object parameters)
このメソッドは、指定したパラメーターに応じたイベントを取得できます。
このメソッドは、削除されたイベントがまだハウスキーパーによって削除されていない場合、削除されたエンティティのイベントを返す場合があります。
このメソッドは、すべてのタイプのユーザーが利用できます。メソッドを呼び出す権限は、ユーザーの役割の設定で取り消すことができます。詳細はユーザーの役割を参照してください。
(object)
希望する出力を定義するパラメータ
このメソッドは、以下のパラメータをサポートしています。
パラメータ | Type | 説明 |
---|---|---|
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. |
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. |
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. |
acknowledged | boolean | If set to true return only acknowledged events. |
suppressed | boolean | true - return only suppressed events;false - return events in the normal state. |
severities | integer/array | Return only events with given event severities. Applies only if object is trigger. |
evaltype | integer | Rules for tag searching. Possible values: 0 - (default) And/Or; 2 - Or. |
tags | array of objects | Return only events with given tags. Exact match by tag and case-insensitive search by value and operator. Format: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...] .An empty array returns all events. Possible operator types: 0 - (default) Like; 1 - Equal; 2 - Not like; 3 - Not equal 4 - Exists; 5 - Not exists. |
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. |
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. |
problem_time_from | timestamp | Returns only events that were in the problem state starting with problem_time_from . Applies only if the source is trigger event and object is trigger. Mandatory if problem_time_till is specified. |
problem_time_till | timestamp | Returns only events that were in the problem state until problem_time_till . Applies only if the source is trigger event and object is trigger. Mandatory if problem_time_from is specified. |
value | integer/array | Return only events with the given values. |
selectHosts | query | Return a hosts property with hosts containing the object that created the event. Supported only for events generated by triggers, items or LLD rules. |
selectRelatedObject | query | Return a relatedObject property with the object that created the event. The type of object returned depends on the event type. |
select_alerts | query | Return an alerts property with alerts generated by the event. Alerts are sorted in reverse chronological order. |
select_acknowledges | query | Return an acknowledges property with event updates. Event updates are sorted in reverse chronological order.The event update object has the following properties: acknowledgeid - (string) acknowledgment's ID;userid - (string) ID of the user that updated the event;eventid - (string) ID of the updated event;clock - (timestamp) time when the event was updated;message - (string) text of the message;action - (integer) update action that was performed see event.acknowledge;old_severity - (integer) event severity before this update action;new_severity - (integer) event severity after this update action;username - (string) username of the user that updated the event;name - (string) name of the user that updated the event;surname - (string) surname of the user that updated the event.Supports count . |
selectTags | query | Return a tags property with event tags. |
selectSuppressionData | query | Return a suppression_data property with the list of maintenances:maintenanceid - (string) ID of the maintenance;suppress_until - (integer) time until the event is suppressed. |
sortfield | string/array | Sort the result by the given properties. Possible values are: eventid , objectid and clock . |
countOutput | boolean | These parameters being common for all get methods are described in detail in the reference commentary page. |
editable | boolean | |
excludeSearch | boolean | |
filter | object | |
limit | integer | |
output | query | |
preservekeys | boolean | |
search | object | |
searchByAny | boolean | |
searchWildcardsEnabled | boolean | |
sortorder | string/array | |
startSearch | boolean |
(integer/array)
次のいずれかを返します:
countOutput
パラメーターが使用されているが、groupBy
パラメータが使用されていない場合、取得したオブジェクトの数groupBy
パラメーターが使用されている場合、集計結果を含むオブジェクトの配列トリガー"22395"から最新のイベントを取得します。
{
"jsonrpc": "2.0",
"method": "event.get",
"params": {
"output": "extend",
"selectAcknowledges": "extend",
"selectSuppressionData": "extend",
"selectTags": "extend",
"objectids": "22395",
"sortfield": ["clock", "eventid"],
"sortorder": "DESC"
},
"id": 1
}
レスポンス:
{
"jsonrpc": "2.0",
"result": [
{
"eventid": "20",
"source": "0",
"object": "0",
"objectid": "22395",
"clock": "1728658089",
"value": "0",
"acknowledged": "0",
"ns": "461809482",
"name": "Load average is too high (per CPU load over 1.5 for 5m)",
"severity": "0",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"cause_eventid": "0",
"acknowledges": [],
"opdata": "Load averages(1m 5m 15m): (1.6328 3.0522 2.2515), # of CPUs: 2",
"suppression_data": [],
"suppressed": "0",
"tags": [
{
"tag": "scope",
"value": "capacity"
},
{
"tag": "scope",
"value": "performance"
},
{
"tag": "component",
"value": "cpu"
},
{
"tag": "class",
"value": "os"
},
{
"tag": "target",
"value": "linux"
}
],
"urls": []
},
{
"eventid": "4",
"source": "0",
"object": "0",
"objectid": "22395",
"clock": "1728657737",
"value": "1",
"acknowledged": "1",
"ns": "460759366",
"name": "Load average is too high (per CPU load over 1.5 for 5m)",
"severity": "3",
"r_eventid": "20",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"cause_eventid": "0",
"acknowledges": [
{
"acknowledgeid": "1",
"userid": "1",
"clock": "1728657938",
"message": "Testing environment. Please disregard this alert.",
"action": "38",
"old_severity": "0",
"new_severity": "0",
"suppress_until": "1728744338",
"taskid": "0",
"username": "Admin",
"name": "Zabbix",
"surname": "Administrator"
}
],
"opdata": "Load averages(1m 5m 15m): (1.6328 3.0522 2.2515), # of CPUs: 2",
"suppression_data": [
{
"maintenanceid": "0",
"suppress_until": "1728744338",
"userid": "1"
}
],
"suppressed": "1",
"tags": [
{
"tag": "scope",
"value": "capacity"
},
{
"tag": "scope",
"value": "performance"
},
{
"tag": "component",
"value": "cpu"
},
{
"tag": "class",
"value": "os"
},
{
"tag": "target",
"value": "linux"
}
],
"urls": []
}
],
"id": 1
}
2012年10月9日から10日までの間に作成されたすべてのイベントを新しい順に取得します。
リクエスト :
{
"jsonrpc": "2.0",
"method": "event.get",
"params": {
"output": "extend",
"time_from": "1349797228",
"time_till": "1350661228",
"sortfield": ["clock", "eventid"],
"sortorder": "desc"
},
"id": 1
}
レスポンス :
{
"jsonrpc": "2.0",
"result": [
{
"eventid": "20616",
"source": "0",
"object": "0",
"objectid": "14282",
"clock": "1350477814",
"value": "1",
"acknowledged": "0",
"ns": "0",
"name": "Less than 25% free in the history cache",
"severity": "3",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"cause_eventid": "0",
"opdata": "",
"suppressed": "0",
"urls": []
},
{
"eventid": "20617",
"source": "0",
"object": "0",
"objectid": "14283",
"clock": "1350477814",
"value": "0",
"acknowledged": "0",
"ns": "0",
"name": "Zabbix trapper processes more than 75% busy",
"severity": "3",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"cause_eventid": "0",
"opdata": "",
"suppressed": "0",
"urls": []
},
{
"eventid": "20618",
"source": "0",
"object": "0",
"objectid": "14284",
"clock": "1350477815",
"value": "1",
"acknowledged": "0",
"ns": "0",
"name": "High ICMP ping loss",
"severity": "3",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"cause_eventid": "0",
"opdata": "",
"suppressed": "0",
"urls": []
}
],
"id": 1
}
ID10のユーザーが承認したイベントを取得する。
リクエス :
{
"jsonrpc": "2.0",
"method": "event.get",
"params": {
"output": "extend",
"action": 2,
"action_userids": [10],
"selectAcknowledges": ["userid", "action"],
"sortfield": ["eventid"],
"sortorder": "DESC"
},
"id": 1
}
レスポンス :
{
"jsonrpc": "2.0",
"result": [
{
"eventid": "1248566",
"source": "0",
"object": "0",
"objectid": "15142",
"clock": "1472457242",
"ns": "209442442",
"r_eventid": "1245468",
"r_clock": "1472457285",
"r_ns": "125644870",
"correlationid": "0",
"userid": "10",
"name": "Zabbix agent on localhost is unreachable for 5 minutes",
"acknowledged": "1",
"severity": "3",
"cause_eventid": "0",
"acknowledges": [
{
"userid": "10",
"action": "2"
}
],
"opdata": "",
"suppressed": "0",
"urls": []
}
],
"id": 1
}
Retrieve the top 5 triggers that have severities "Warning", "Average", "High", or "Disaster", together with the number of problem events within a specified time period. 深刻度"Warning"、"Average"、"High"、"Disaster"を持つ上位5つのトリガーと、指定された期間内の障害イベントの数を取得します。
リクエスト :
{
"jsonrpc": "2.0",
"method": "event.get",
"params": {
"countOutput": true,
"groupBy": "objectid",
"source": 0,
"object": 0,
"value": 1,
"time_from": 1672531200,
"time_till": 1677628800,
"trigger_severities": [2, 3, 4, 5],
"sortfield": ["rowscount"],
"sortorder": "DESC",
"limit": 5
},
"id": 1
}
レスポンス :
{
"jsonrpc": "2.0",
"result": [
{
"objectid": "232124",
"rowscount": "27"
},
{
"objectid": "29055",
"rowscount": "23"
},
{
"objectid": "253731",
"rowscount": "18"
},
{
"objectid": "254062",
"rowscount": "11"
},
{
"objectid": "23216",
"rowscount": "7"
}
],
"id": 1
}
CEvent::get() in ui/include/classes/api/services/CEvent.php.