[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: PNG File 1-ItemPrototype-def.png     PNG File 2-ItemPrototype-preprocessing.png     PNG File 3-JSONPath-Error.png     PNG File 4-LLDMacros.png     PNG File 6-JSONPath-1-totalsuccess.png     PNG File 6-JSONPath-Test.png     PNG File Sin título.png     PNG File Sin título2.png    

 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 }]

 

  • Then, a LLD rule based on the content of that file creates several items from prototypes. These items are dependent items from the json master item and are supposed to return the values of the different "total_" fields of the json thanks to jsonpath preprocessing (see attachment). The preprocessing is defined that way : *$.total_success (attachment 2)
  • In these items names, I use LLD macros, to get values from the json, and it works fine (attachment 1, 3 and 4).

 

  • But I get an error with my protoype items values  (see attachement 3) :

"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,
Eduards

Comment by Alexei Vladishev [ 2022 Feb 11 ]

I believe we can close it. Feel free to re-open.

Generated at Sun Apr 27 11:10:53 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.