[ZBXNEXT-2132] Accept offset parameter for API calls Created: 2014 Jan 28 Updated: 2025 Feb 07 |
|
Status: | Open |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | API (A) |
Affects Version/s: | 2.2.1 |
Fix Version/s: | None |
Type: | Change Request | Priority: | Trivial |
Reporter: | Corey Shaw | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 25 |
Labels: | limits, pagination, patch, performance | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() ![]() |
||||||||||||
Issue Links: |
|
Description |
While it is useful to have the "limit" parameter in API requests, it's use would be greatly enhanced if an "offset" parameter existed as well. Let's say I have 10,000 history rows to retrieve through the API. It would make sense to not only be able to limit the result to 2000 rows at a time, but also submit an offset that so that I can first get the first 2000, then the next 2000, etc. I created a patch to do this in 2.2.x and it was a trivial addition to add it only for history.get. I'm not sure what would have to be done to add it everywhere. |
Comments |
Comment by Corey Shaw [ 2014 Jan 28 ] |
This was very easy to add because the DBselect() function already supportes an offset parameter. |
Comment by Oleksii Zagorskyi [ 2014 Jan 31 ] |
See also ZBXNEXT-1503 |
Comment by Norimitsu Sugimoto [ 2016 May 05 ] |
support offset parameter history.get() for zabbix-3.0.2 |
Comment by Norimitsu Sugimoto [ 2016 May 05 ] |
Useful offset parameter. I rewrote the patch for zabbix-3.0.2. see attached file. |
Comment by vitalijs.cemeris (Inactive) [ 2016 Aug 02 ] |
Adding offset could lead to changing "Search/Filter elements limit" GUI configuration option to "Maximum rows per page". |
Comment by Naga Maheswara Reddy Palem [ 2021 Mar 31 ] |
Having pagenation support will help for other system integrations. When the historyget or items.get has more results its throwing 500 internal error. Pagination helps in api calls usecases |
Comment by Marcel Renner [ 2022 May 30 ] |
+1 It would also be useful in PowerShell to paging/piping the results in small badges. For example, we use PowerShell to synchronize the inventory data of all hosts with our CMDB via the API. But when you have 10,000 hosts, this can quickly lead to problems. Something like in SQL with offsets and limits would be great. |
Comment by S K [ 2024 Feb 09 ] |
Are there any news regarding this feature? |
Comment by dimir [ 2024 Feb 12 ] |
It's possible that the cause of this feature missing was support of things like "limit, offset" back in the days when we supported more database backends (like IBM DB2) which either don't have it or didn't have it back then. We now do not support IBM DB2 so the only question is Oracle. According to this support for limiting and specifying offset was added to Oracle 12c. This should be fine since we require at least version 19c at this point. I'll try to get more information. |
Comment by dimir [ 2024 Feb 13 ] |
simkimdm While this is still not implemented, would it work for you if you'd fetch the list of all hostids first and then go on handling them by smaller batches? Have you tried it? |
Comment by S K [ 2024 Feb 14 ] |
@dimir works better than fetching all at once. thank you. from zabbix_utils import ZabbixAPI // ... login stuff def get_zabbix_hosts(): zabbix_hosts_ids = zabbix.host.get( output="hostid", evaltype=0, tags=[ { "tag": "cmdb_id", "operator": 4 } ] ) chunk_size = 1000 chunks = [chunk['hostid'] for chunk in zabbix_hosts_ids] zabbix_hosts = [] for i in range(0, len(chunks), chunk_size): chunk = chunks[i:i + chunk_size] zabbix_hosts += zabbix.host.get(hostids=chunk, selectMacros="extend", selectTags="extend", selectHostGroups="extend", selectParentTemplates="extend", selectInterfaces="extend") return zabbix_hosts |
Comment by dimir [ 2024 Feb 14 ] |
Nice. And nice to see you use our zabbix_utils and it works for you. |