integer/array history.get(object parameters)
该方法允许根据给定的参数检索历史数据。
参考: 已知问题
<note important>如果内置数据管理housekeeper尚未移除已删除实体的历史数据,则此方法可能会返回该数据。 :::
(object) 定义期望输出的参数。
该方法支持以下参数:
| 参数 [ | 型](/zh/manual/api/reference_commentary#data_types) 描述 | |
|---|---|---|
| history | 整数 要 | 回的历史对象类型。 可能的值: 0 - 数字浮点; 1 - 字符串; 2 - 日志; 3 - 无符号数字; 4 - 文本。 默认值: 3。 |
| hostids | 字符串/数组 只返回给 | 主机的历史记录。 |
| itemids | 字符串/数组 只返回给 | 监控项的历史记录。 |
| time_from | 时间戳 仅返 | 在给定时间时或之后收到的值。 |
| time_till | 时间戳 仅返 | 在给定时间时或之前收到的值。 |
| sortfield | 字符串/数组 按照给定 | 属性对结果进行排序。 可能的值: itemid 和 clock。 |
| countOutput | 布尔值 这些 | 数对于所有get方法都是通用的,详细描述可参考: 注释参考。 |
| editable | 布尔值 :: | |
| excludeSearch | 布尔值 :: | |
| filter | 对象 : | : |
| limit | 整数 : | : |
| output | 查询 : | : |
| search | 对象 : | : |
| searchByAny | 布尔值 :: | |
| searchWildcardsEnabled | 布尔值 :: | |
| sortorder | 字符串/数组 ::: | |
| startSearch | 布尔值 :: | |
(integer/array) 返回任一:
countOutput参数,返回检索对象的数量从数字(浮点)监控项中获取最近10条数据
请求:
{ "jsonrpc": "2.0", "method": "history.get", "params": { "output": "extend", "history": 0, "itemids": "23296", "sortfield": "clock", "sortorder": "DESC", "limit": 10 }, "auth": "038e1d7b1735c6a5436ee9eae095879e", "id": 1 }响应:
{ "jsonrpc": "2.0", "result": [ { "itemid": "23296", "clock": "1351090996", "value": "0.0850", "ns": "563157632" }, { "itemid": "23296", "clock": "1351090936", "value": "0.1600", "ns": "549216402" }, { "itemid": "23296", "clock": "1351090876", "value": "0.1800", "ns": "537418114" }, { "itemid": "23296", "clock": "1351090816", "value": "0.2100", "ns": "522659528" }, { "itemid": "23296", "clock": "1351090756", "value": "0.2150", "ns": "507809457" }, { "itemid": "23296", "clock": "1351090696", "value": "0.2550", "ns": "495509699" }, { "itemid": "23296", "clock": "1351090636", "value": "0.3600", "ns": "477708209" }, { "itemid": "23296", "clock": "1351090576", "value": "0.3750", "ns": "463251343" }, { "itemid": "23296", "clock": "1351090516", "value": "0.3150", "ns": "447947017" }, { "itemid": "23296", "clock": "1351090456", "value": "0.2750", "ns": "435307141" } ], "id": 1 }CHistory::get() in ui/include/classes/api/services/CHistory.php.