Ad Widget

Collapse

Item json path preprocessing issue

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ezols
    Member
    • Dec 2021
    • 33

    #1

    Item json path preprocessing issue

    Hello, could you please advise whats wrong.
    I have created an item with preprocesing on json path - $.value[0].timeseries[0].data[59].maximum
    Click image for larger version

Name:	image.png
Views:	1902
Size:	17.2 KB
ID:	460787
    I have tested the step:
    Click image for larger version

Name:	image.png
Views:	1843
Size:	21.5 KB
ID:	460789
    I got the value what i needed, but when i check on item i have these problems:
    Code:
    Preprocessing failed for: "timeStamp": "2023-03-09T13:40:00+00:00",
    1. Failed: cannot extract value from json by path "$.value[0].timeseries[0].data[59].maximum": invalid object format, expected opening character '{' or '[' at: '"timeStamp": "2023-03-09T13:40:00+00:00",'​
    I have attached json.txt in which is json content from which im try to retrieve last(59th) value of "maximum"

    I have validated json path in validation tool and got the needed result:
    Click image for larger version

Name:	image.png
Views:	1852
Size:	141.7 KB
ID:	460790
    Could you please advise whats wrong?

    Thanks. ​​
  • Answer selected by Markku at 02-07-2024, 16:25.
    D-with89
    Junior Member
    • Jul 2024
    • 2

    Hi

    I managed to find out that is actually works, only the test buttons returns error, while the latest message returned the correct value. I have created the trigger with it and know I get the notifications properly.
    I am pretty sure it's JSON data, I have tested it with different validators without any issue.

    David

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #2
      yeah, the example data seems OK.. That "timeStamp": "2023-03-09T13:40:00+00:00" is not from example data... Are you sure that if you pull that data from host, it is actually complete and correct...Maybe its broken json....

      Comment

      • ezols
        Member
        • Dec 2021
        • 33

        #3
        im not 100% sure if json is not broken, looks ok, but to avoid this i just got needed data directly on host with the same json path and got needed results, no errors on host about timestamps
        az monitor metrics list --resource "" --metric cpu_percent --aggregation maximum | jq '.value[].timeseries[].data[59].maximum'
        post can be closed, workaround implemented.

        Comment

        • Theolude
          Junior Member
          • Apr 2011
          • 13

          #4
          Hello,

          I've exactly the same issue.

          I produce a JSON dataset from a webservice called by Zabbix server.
          The JSON dataset is correctly build by the webservice, i can get it by different ways and it's always OK.

          When i try to test the JSON string with Zabbix pretreatment associate to the item, i've got the right value, and no errors in JSON.
          Click image for larger version

Name:	image.png
Views:	1564
Size:	18.6 KB
ID:	469548

          Nevertheless, the server console warn me that ... as he's not received the JSON ...

          Click image for larger version

Name:	image.png
Views:	1555
Size:	10.7 KB
ID:	469547

          I'm lost, and need help

          Best regards, Théo

          Comment

          • D-with89
            Junior Member
            • Jul 2024
            • 2

            #5
            Hello Everybody,

            I have the same issue, and I cannot find the solution... Does anybody managed to fix it in the meantime? I use the 7.0 LTS version on Ubuntu 22.04 with MySQL (native version, no docker)

            Thank you in advance.

            Best regards,
            David

            Comment

            • Markku
              Senior Member
              Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
              • Sep 2018
              • 1782

              #6
              The error message says that the item input data is not JSON.

              Markku

              Comment

              • D-with89
                Junior Member
                • Jul 2024
                • 2

                #7
                Hi

                I managed to find out that is actually works, only the test buttons returns error, while the latest message returned the correct value. I have created the trigger with it and know I get the notifications properly.
                I am pretty sure it's JSON data, I have tested it with different validators without any issue.

                David

                Comment

                • NLukas77
                  Junior Member
                  • Jul 2024
                  • 1

                  #8
                  Hi, I have solved the same issue. JSON seamed OK, JSONpath Evaluation said OK, but zabbix wrote still error code. I have used javascript in preprocessing for the masteritem.

                  var cleanValue = value.replace(/^\uFEFF/, '');
                  return cleanValue;

                  Issue is solved now

                  Comment

                  Working...