Ad Widget

Collapse

Unsupported JSON character in JSONPath starting with ...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hozzer
    Junior Member
    • Sep 2019
    • 1

    #1

    Unsupported JSON character in JSONPath starting with ...

    Hi,

    I'm using Zabbix Server 4.2.3 and have been following this doc, https://www.zabbix.com/documentation...items/jsonpath.

    I have copied the JSON input data and inserted into a Value for Test Item preprocessing.

    I then run some tests in which the JSONPath Parameters match up with the examples toward the bottom of the same doc mentioned above.

    Out of all the examples given, only the following work as intended and return a result:

    $.filters.price
    $.filters.category
    $.filters['no filters']
    $.filters
    $.books[1].title


    ALL others result in unsupported errors, two examples:

    cannot extract value from json by path "$.books[-1].author": unsupported character in json path starting with: "[-1].author"
    cannot extract value from json by path "$.services[?(@.active==“false”)].servicegroup": unsupported character in json path starting with: "[?(@.active==“false”)].servicegroup"


    Does anyone have any troubleshooting advice?

  • gofree
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2017
    • 400

    #2
    Try replace " with ' in active == 'false '

    Comment


    • hozzer
      hozzer commented
      Editing a comment
      Thanks for you response but unfortunately I can still see the error:
      cannot extract value from json by path "$.services[?(@.active=='false')].servicegroup": object not found starting with json path: "services[?(@.active=='false')].servicegroup"
      cannot extract value from json by path "$.services[?(@.active == 'false')].servicegroup": object not found starting with json path: "services[?(@.active == 'false')].servicegroup"

      This also does not explain why the simpler $.books[-1].author parameter is not supported.
  • gofree
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2017
    • 400

    #3
    work in mine no issue , try to upgrade to 4.2.6 just in case there has been some bug in 4.2.3

    more likely you didnt copy it properly ( json data ) - double check

    Click image for larger version  Name:	test.png Views:	1 Size:	30.8 KB ID:	385782


    Click image for larger version

Name:	test2.png
Views:	8120
Size:	28.5 KB
ID:	385783
    Last edited by gofree; 05-09-2019, 18:00.

    Comment

    • chojin
      Member
      Zabbix Certified Specialist
      • Jul 2011
      • 64

      #4
      I see the same kind of behaviour:
      I have a master item that gets item data like this:
      Code:
      {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-20190914_160232","AutoFullBackup-20190915_160343","AutoFullBackup-20190916_160453","AutoFullBackup-20190917_160606","AutoFullBackup-20190918_160716","AutoFullBackup-20190919_160835","AutoFullBackup-20190920_161000","AutoFullBackup-20190921_161111","AutoFullBackup-20190922_161219","AutoFullBackup-20190924_140600","AutoFullBackup-20190925_140714","AutoFullBackup-20190926_140825","AutoFullBackup-20190927_140940","AutoFullBackup-20190928_141050","AutoFullBackup-20190929_141200","AutoFullBackup-20190930_141312","AutoFullBackup-20191001_141426","AutoFullBackup-20191002_141541","AutoFullBackup-20191003_141651"]}
      Then I have 2 dependent items which turn to unsupported with an error:
      • Item: Number of backups
        Preprocessing: JSONPath: $.strings.length()
        Error:
        Preprocessing failed for: {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-201...
        1. Failed: cannot extract value from json by path "$.strings.length()": object not found starting with json path: "length()"
      • Item: Last backup
        Preprocessing: JSONPath: $.strings[-1]
        Error:
        Preprocessing failed for: {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-201...
        1. Failed: cannot extract value from json by path "$.strings[-1]": unsupported character in json path starting with: "[-1]"
      When I copy-paste the data from the master item into the Preprocessing test dialog of the UI.. I do get the expected results:
      For Item 1 I get "21" as test result
      and for item 2 I get "AutoFullBackup-20191003_141651" as test result

      So why are those items turning unsupported with errors which suggest that json path does not understand the function length() and instead tries to find a key "length()" and that it does not seems to understand negative array indexes ?

      I have read the documentation many times to check if I make some stupid mistake.. but I don't see the problem..
      Also the tests using the UI turn out exactly as expected..
      Is JSONpath in zabbix server partly broken ?
      (Running version 2.4.7)

      As the JSON test vs the actual result give totally different values, I opened a bug: https://support.zabbix.com/browse/ZBX-16727
      Last edited by chojin; 04-10-2019, 15:35. Reason: Added bug report

      Comment

      • chojin
        Member
        Zabbix Certified Specialist
        • Jul 2011
        • 64

        #5
        It seems my problem was caused by a <4.2.5 zabbix proxy, not yet supporting those jsonpath notations. Upgrading the proxy, or monitoring those items without proxy, solved the problem.

        The tester in the web UI uses the server to test the item hence the correct evalutation. But the actual preprocessing of the items is done by the proxy itself.
        Last edited by chojin; 07-10-2019, 10:39.

        Comment

        Working...