Ad Widget

Collapse

JSONPATH value syntx not correct

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lslamp
    Member
    • Jan 2020
    • 33

    #1

    JSONPATH value syntx not correct

    I am trying to extract a value from a JSON query, but it is not accepting the value that I am inserting.
    The confusing thing is that if I run the same value within a JSON online tester, I a syntax error.

    below is the result of running the following command.

    zabbix_get -s 127.0.0.1 -k speedtest-cli

    resulting data.
    {"download": 728279569.2356068, "upload": 673805038.8042076, "ping": 7.978, "server": {"url": "http://speedtest.trined.nl:8080/speedtest/upload.php", "lat": "xxxxxx", "lon": "xxxxx", "name": "Sint-Oedenrode", "country": "Netherlands", "cc": "NL", "sponsor": "TriNed B.V.", "id": "xxxxxx", "host": "speedtest.trined.nl:8080", "d": 21.930530770089096, "latency": 7.978}, "timestamp": "2020-12-09T08:05:38.034802Z", "bytes_sent": 151519232, "bytes_received": 409373932, "share": null, "client": {"ip": "xxx.xxx.xxx.xxx", "lat": "xxxxxxx", "lon": "xxxxxx", "isp": "CAIW Internet", "isprating": "3.7", "rating": "0", "ispdlavg": "0", "ispulavg": "0", "loggedin": "0", "country": "NL"}}

    within an online portal https://www.jsonquerytool.com/ I test the following value $.server.latency and get a result below. which if you look at the output above, that matches the latency value. This is what I am looking to get.

    Click image for larger version

Name:	json_query_result.png
Views:	219
Size:	8.0 KB
ID:	414884

    So with this logic, I created an item and within that item I added pre-processing.
    Click image for larger version

Name:	pre-processing.png
Views:	209
Size:	23.2 KB
ID:	414885

    I am trying to extract the latecy to my ISP server.

    Click image for larger version

Name:	pre-processing_jsonpath.png
Views:	178
Size:	14.6 KB
ID:	414886

    The issue is when I use the tested online query value, it fails the test.
    Click image for larger version

Name:	latency_test.png
Views:	195
Size:	16.8 KB
ID:	414887

    After running the test from within the zabbix test, I get the following error.

    Click image for larger version

Name:	latency_test_error.png
Views:	213
Size:	28.6 KB
ID:	414888

    I have tried to place both { and [ brackets in various locations and I cannot get any of them to pass the test.

    What is wrong with my syntax.

    Any ideas, any help is appreciated.

    Thanks
    Lawrence
  • Matgou
    Junior Member
    • Nov 2020
    • 4

    #2
    Hi Lawrence,

    I think you use Test with incorrect value. In "Test Item" screen you should set JSON data in Value field like :

    Click image for larger version

Name:	Capture d’écran du 2020-12-09 13-21-01.png
Views:	188
Size:	20.0 KB
ID:	414902
    Best,
    Mathieu

    Comment

    • lslamp
      Member
      • Jan 2020
      • 33

      #3
      Matgou
      thanks for your pointer. This solved my problem.

      Click image for larger version

Name:	latency_dashboard.png
Views:	192
Size:	11.4 KB
ID:	414945

      Thanks
      Lawrence

      PS: if you know about the value field, do you perhaps know anything about the vbs.file.content[file.<encoding>] and how it works.
      If so please take a look at https://www.zabbix.com/forum/zabbix-...d-on-dashboard

      Thanks
      Lawrence

      Comment

      Working...