history_get
Retrieve historical data from Zabbix by specifying item IDs, time range, history type, and sorting preferences. Outputs JSON-formatted results for analysis or integration.
Instructions
Get history data from Zabbix.
Args:
itemids: List of item IDs to get history for
history: History type (0=float, 1=character, 2=log, 3=unsigned, 4=text)
time_from: Start time (Unix timestamp)
time_till: End time (Unix timestamp)
limit: Maximum number of results
sortfield: Field to sort by
sortorder: Sort order (ASC or DESC)
Returns:
str: JSON formatted history data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| history | No | ||
| itemids | Yes | ||
| limit | No | ||
| sortfield | No | clock | |
| sortorder | No | DESC | |
| time_from | No | ||
| time_till | No |
Input Schema (JSON Schema)
{
"properties": {
"history": {
"default": 0,
"title": "History",
"type": "integer"
},
"itemids": {
"items": {
"type": "string"
},
"title": "Itemids",
"type": "array"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"sortfield": {
"default": "clock",
"title": "Sortfield",
"type": "string"
},
"sortorder": {
"default": "DESC",
"title": "Sortorder",
"type": "string"
},
"time_from": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Time From"
},
"time_till": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Time Till"
}
},
"required": [
"itemids"
],
"type": "object"
}
Implementation Reference
- src/zabbix_mcp_server.py:841-879 (handler)The main handler function for the 'history_get' tool. It retrieves history data from the Zabbix API using the provided itemids and parameters, formats the parameters into a dict, calls client.history.get(**params), and returns the JSON-formatted result.@mcp.tool() def history_get(itemids: List[str], history: int = 0, time_from: Optional[int] = None, time_till: Optional[int] = None, limit: Optional[int] = None, sortfield: str = "clock", sortorder: str = "DESC") -> str: """Get history data from Zabbix. Args: itemids: List of item IDs to get history for history: History type (0=float, 1=character, 2=log, 3=unsigned, 4=text) time_from: Start time (Unix timestamp) time_till: End time (Unix timestamp) limit: Maximum number of results sortfield: Field to sort by sortorder: Sort order (ASC or DESC) Returns: str: JSON formatted history data """ client = get_zabbix_client() params = { "itemids": itemids, "history": history, "sortfield": sortfield, "sortorder": sortorder } if time_from: params["time_from"] = time_from if time_till: params["time_till"] = time_till if limit: params["limit"] = limit result = client.history.get(**params) return format_response(result)