[ZBX-17535] JSON Path preprocessing not working in dependent items Created: 2020 Mar 31 Updated: 2022 Feb 11 Resolved: 2022 Feb 11 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 4.2.8 |
Fix Version/s: | None |
Type: | Incident report | Priority: | Trivial |
Reporter: | FK | Assignee: | Unassigned |
Resolution: | Won't fix | Votes: | 2 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Description |
Hello, I created a template with a system.run master item returning JSON (both in standard output and in a file) : [ { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5c56f986fe09e73cf21b5b66", "hour" : "21" , "total_success" : 3, "total_failures" : 0, "total_calls" : 3 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5e74b52bae1cf600e62ec3dd", "hour" : "21" , "total_success" : 2, "total_failures" : 0, "total_calls" : 2 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5e74b52bae1cf600e62ec3e0", "hour" : "21" , "total_success" : 1, "total_failures" : 0, "total_calls" : 1 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5c97ffb5ae1cf63c222c11d3", "hour" : "21" , "total_success" : 743, "total_failures" : 0, "total_calls" : 743 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5c97f547ae1cf63c351a155a", "hour" : "21" , "total_success" : 24, "total_failures" : 0, "total_calls" : 24 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5d32d51cfe09e7e38d57884e", "hour" : "21" , "total_success" : 297, "total_failures" : 0, "total_calls" : 297 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5c56fe95fe09e78cac2ca04c", "hour" : "21" , "total_success" : 10, "total_failures" : 0, "total_calls" : 10 }, { "api_id" : "5c97f547ae1cf63c351a1552", "function_id" : "5c45ef1ffe09e757db7b1951", "hour" : "21" , "total_success" : 297, "total_failures" : 0, "total_calls" : 297 }]
"Preprocessing failed for [...]. Failed: cannot extract value from json by path "$.total_success". object not found starting with json path: "total_success"
NB : Sythax "$[1].total_success" works, but only get first occurence of total_success value fr each item... Not really useful... Syntax "$[*].total_success" or "$..total_success" don't work...
Do you have any idea why my jsonpath definition works fine in the names of the items (from my LLD macros), but not in the values of the items (from the preprocessing jsonpath) please ?
|
Comments |
Comment by Elias Pizarro [ 2020 Apr 03 ] |
Not only this but, also if i have this json or any simple json, can't be processed [{ "1": "2020-04-02 19:47:05.645 ", "2": " 152.172.210.37 ", "3": " 172.16.39.18 ", "4": " caguilar ", "5": " DISCONNECT" } ] |
Comment by Glebs Ivanovskis [ 2020 Apr 04 ] |
With JSONPath $.[1] in the comment above you are trying to get the value of key "1" from an object, your example JSON is an array of objects, so you need to get to array element first. I don't know why your example "works" in online JSONPath evaluator, but I guess it shouldn't work like this. |
Comment by FK [ 2020 Apr 06 ] |
As I said, the synthax $[1].total_success works fine, but of course returns the first entry of total_success for each item, which isn't very useful (see attachments 6). I need to get each total_success for each item prototype. Do you need more info ?
|
Comment by Elias Pizarro [ 2020 Apr 08 ] |
no, thanks |
Comment by Eduards Matuls (Inactive) [ 2020 Jun 19 ] |
Hello! I guess this is a logical issue. With "$[*].total_success" you are trying to store 8 different values to 1 item. It doesn't work this way. Zabbix should know exactly which value to store. I guess you have to redesign your LLD rule and item prototypes logic. LLD in this case works because of it's design. LLD should be able to find multiple items and return it as an array of LLD macros. Regards, |
Comment by Alexei Vladishev [ 2022 Feb 11 ] |
I believe we can close it. Feel free to re-open. |