[ZBX-14980] API 3.4.14 problem with filter by itemid in history.get Created: 2018 Oct 09 Updated: 2024 Apr 10 Resolved: 2019 Jan 05 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 3.4.14, 4.0.0 |
Fix Version/s: | 4.0.4rc1, 4.2.0alpha3, 4.2 (plan) |
Type: | Problem report | Priority: | Critical |
Reporter: | Gustavo Guido | Assignee: | Vasily Goncharenko (Inactive) |
Resolution: | Fixed | Votes: | 0 |
Labels: | filters, history.get | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Centos 7, Ubutnu Xenial |
Attachments: | result.log screenshot-1.png screenshot-2.png screenshot-3.png screenshot-4.png show-latest-values.py | ||||||||
Issue Links: |
|
||||||||
Team: | Team D | ||||||||
Team: | Team D | ||||||||
Sprint: | Sprint 45, Sprint 46, Nov 2018, Sprint 47, Dec 2018 | ||||||||
Story Points: | 0.5 |
Description |
Steps to reproduce:
Result: returns all the history values for all the items of the host Expected: Work arround: specify the filter filter like z.history.get(hostids=10350, itemids=46525, history=0, time_from=1538132400.0, time_till=1538136000.0, sortfield='clock', sortorder='ASC', filter={"itemid":"46525"})
|
Comments |
Comment by Aigars Kadikis [ 2018 Oct 22 ] |
Hello Gustavo, It is even possible to use pure filter function like: z.history.get(filter={"itemid":"46525"}, history=0, time_from=1538132400.0, time_till=1538136000.0, sortfield='clock', sortorder='ASC') When using itemids as a parameter it does not create any impact on a result. Either it is a bug or documentation task. Reference: |
Comment by Aigars Kadikis [ 2018 Oct 22 ] |
I am using show-latest-values.py code to get 'Free swap space' values on 'Zabbix server' in lastet 5 minutes. Both approaches are executed: # Execute only filter and use 'itemid': zapi.history.get(filter={"itemid":"23309"},history=3, time_from = ctime-300, time_till = ctime) # Use parameters: 'hostids' and 'itemids': zapi.history.get(hostids=10084,itemids=23309,history=3, time_from = ctime-300, time_till = ctime) The result is: result.log |
Comment by Gustavo Guido [ 2018 Oct 22 ] |
Hello Aigars That's right, we agree in the work arround, but the problem still there. We try it in the 4.0, and the same thing ocurs If we take away de hostid filter, it works properly, retriving just the specified item. May be now its an "or" between the conditions where it use to be an "and" ? In my opinion, it should be an "and" Regards
|
Comment by Vasily Goncharenko (Inactive) [ 2018 Oct 29 ] |
This behavior can be explained as follows: We observe that the list of items is used as a filter directly to the history and the request is executed correctly. Now we will only request a list of hosts ( 'hostids' => [99032, 99033]): Observe that when the hosids parameter is present in the request, before performing the history query, another request is made to the hosts and all items of the selected hosts are retrieved. Next, we indicate a specific host and specific item: All items of the specified host have been selected, but the specified item 99144 seems to have been ignored. Finally, let's execute another query. Request a list of hosts and a specific item: Now we observe that only the specified item was selected and it seems that the entire list of hosts was ignored. |
Comment by richlv [ 2018 Oct 29 ] |
This might be another case of API validation (ZBX-3783) - it seems like hostid and itemid should be mutually exclusive in this case. |
Comment by Gustavo Guido [ 2018 Oct 29 ] |
Hi everyone I think richlv has a point here, and is logical, if there is an itemid specified, you can discard the hostid, since the item will determine to which host it belongs to. Never the less, if they are both specified, the result should not change. Greetings |
Comment by richlv [ 2018 Oct 29 ] |
I'd prefer the API rejecting requests with both hostid and itemid. Less ambiguity than ignoring some parameters in some cases. |
Comment by Valdis Murzins [ 2018 Nov 01 ] |
API response should contain only entities, that match all provided filters. So, in this case, if you are using both "hostids" and "itemids" filters, in response you should get history for items that match both conditions:
As it currently is not working like this for history.get API method, it should be fixed. |
Comment by richlv [ 2018 Nov 13 ] |
Validation-wise, I cannot come up with a case where it would make sense to specify both hostid and itemid, it seems like a bad request - but that's hardly a critical issue. |
Comment by Gustavo Guido [ 2018 Nov 15 ] |
richlv, is not working like used to, this is enaugh, I think, to fix it, and is this the reason why is critical, the scripts you have already develop and deploy are not working like they did A case wich you must specify both, if a user is using a script, he can specify both. |
Comment by richlv [ 2018 Nov 15 ] |
Sorry, I didn't follow that - while I agree that the current behaviour is not correct, I don't see a benefit from accepting redundant parameters. Is there a usecase I'm missing? |
Comment by Gustavo Guido [ 2018 Nov 15 ] |
That's what matters, we agree that the current behaviour is not correct.
|
Comment by Vasily Goncharenko (Inactive) [ 2019 Jan 03 ] |
Fixed in:
|