Ad Widget

Collapse

JSON Path preprocessing not working in dependent items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zabbixuserfk
    Member
    • Apr 2020
    • 37

    #1

    JSON Path preprocessing not working in dependent items

    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)

      Click image for larger version

Name:	2-ItemPrototype-preprocessing.png
Views:	1434
Size:	19.2 KB
ID:	398694
    • In these items names, I use LLD macros, to get values from the json, and it works fine (attachment 1, 3 and 4).

    Click image for larger version

Name:	1-ItemPrototype-def.png
Views:	1456
Size:	37.8 KB
ID:	398695
    • Click image for larger version

Name:	4-LLDMacros.png
Views:	1387
Size:	29.5 KB
ID:	398698
    • But I get an error with my protoype items values (see attachement 3) :

    Click image for larger version

Name:	3-JSONPath-Error.png
Views:	1426
Size:	46.0 KB
ID:	398697

    "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 ?


    Attached Files
Working...