Ad Widget

Collapse

Cannot parse as a valid JSON object for custom discovery rule

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Valelinn
    Junior Member
    • Feb 2018
    • 8

    #1

    Cannot parse as a valid JSON object for custom discovery rule

    Hello,

    I'm running Zabbix 5.0.2, and I've trying to create a custom discovery rule. I tried a very simple test to see how this works:
    1. I created a discovery rule on a host with key "test.discovery".
    2. From the Zabbix server itself, I run the following command: zabbix_sender -z 127.0.0.1 -s "testhost" -k test.discovery -o {"{#SITENAME}":"test.com"}
    3. However, Zabbix gives me the following error message:
      Invalid discovery rule value: cannot parse as a valid JSON object: invalid object name at: '{#SITENAME}:test.com}'
    I've tried different variations of the JSON value:
    • [{"{#SITENAME}":"test.com"}]
    • "{"{#SITENAME}":"test.com"}"
    • "[{"{#SITENAME}":"test.com"}]"
    but all just return the same result.

    I'm really at a loss here as to what I'm doing wrong. Any assistance would be appreciated.
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #2
    Bash strips out your double quotes. In order to be on the safe side always single-quote the while json value:
    Code:
    zabbix_sender -z 127.0.0.1 -s testhost -k test.discovery -o '[{"{#SITENAME}":"test.com"}]'

    Comment

    • moora
      Junior Member
      • Dec 2021
      • 5

      #3
      I have similiar problem:
      1511:20221105:165212.896 cannot process returned result: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'OK'
      is there i way to find out in which item the problem is happening?
      I will then use the recommended solutions from you, but the json is so short, I cannot find it

      Thak you

      Comment

      • markfree
        Senior Member
        • Apr 2019
        • 868

        #4
        Originally posted by moora
        I have similiar problem:
        1511:20221105:165212.896 cannot process returned result: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'OK'
        is there i way to find out in which item the problem is happening?
        I will then use the recommended solutions from you, but the json is so short, I cannot find it
        I have an environment with the same issue and I could not find any error in any Discovery rule.
        ffg

        Comment

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

          #5
          Can you markfree post the JSON here?

          The previous poster had a simple problem: plain string OK is not valid JSON for sure.

          Markku

          Comment

          • markfree
            Senior Member
            • Apr 2019
            • 868

            #6
            Originally posted by Markku
            Can you markfree post the JSON here?
            The previous poster had a simple problem: plain string OK is not valid JSON for sure.
            My issue is exactly like moora's.
            Like him, I cannot find where that string is coming from.

            Comment

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

              #7
              Can you then show the discovery rule configuration with relevant scripts if present, and the output of the discovery rule key? Note also the preprocessing rules.

              Markku

              Comment

              • moora
                Junior Member
                • Dec 2021
                • 5

                #8
                Originally posted by Markku
                Can you then show the discovery rule configuration with relevant scripts if present, and the output of the discovery rule key? Note also the preprocessing rules.

                Markku
                I see the problem in the zabbix log - I have no idea vwhere it is comming from

                Comment

                Working...