Ad Widget

Collapse

LLD Discovery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • focar
    Junior Member
    • Dec 2023
    • 17

    #1

    LLD Discovery

    Hello all

    I'm creating a discovery template for some device. I have an issue which keeps returning "Cannot find the "data" array in the received JSON object"
    All items tests show correct output. Could this be a bug or am i to blame here. Any feedback would be appreciated.


    Click image for larger version  Name:	image.png Views:	0 Size:	17.6 KB ID:	497750

    The template item:

    Click image for larger version  Name:	image.png Views:	0 Size:	104.0 KB ID:	497751

    Click image for larger version

Name:	image.png
Views:	137
Size:	93.9 KB
ID:	497756


    Discovery Rule
    Click image for larger version  Name:	image.png Views:	0 Size:	48.7 KB ID:	497753






    The confusion i have here is that the error shows "data" but i'm requesting the "access_token" data field.

    For sake i already tried to preprocess replace the access_token to data but this did not help either.


    Many thanks for taking a look at this and provide some feedback





    Attached Files
    Last edited by focar; 23-01-2025, 18:42.
  • kyus
    Senior Member
    • Feb 2024
    • 172

    #2
    Hey!

    Can you explain what your item is supposed to do?
    The item that failed is dependent on your HTTP item?
    If I understood your setup correctly, it seems like the only value received by your item is the token itself...

    Comment

    • focar
      Junior Member
      • Dec 2023
      • 17

      #3
      Hi Kyus

      Thanks for your reply

      In essence the item should return a token that i can use as a macro for other items that need Oauth2 authentication. Indeed, the discovery item is a dependent from an item that exists in the template.

      Comment

      • focar
        Junior Member
        • Dec 2023
        • 17

        #4
        Hey

        Maybe worth mentioning. Another way of trying to achieve my goal was to create an item that populates a host inventory field. This works well but this macro {INVENTORY.ALIAS} is not allowed (or does not work) for use in Items.... .


        Click image for larger version

Name:	image.png
Views:	138
Size:	40.7 KB
ID:	497798

        Click image for larger version

Name:	image.png
Views:	125
Size:	33.2 KB
ID:	497799



        Comment

        • kyus
          Senior Member
          • Feb 2024
          • 172

          #5
          You can store this token in a LLD Macro in your "something.token.set" discovery rule. Then you can use the LLD Macro in Item Prototypes.

          Comment

          • focar
            Junior Member
            • Dec 2023
            • 17

            #6
            Hi kuys

            That is the reason for opening this topic. It does not work when i try to LLD this: it gives me this output:

            Click image for larger version

Name:	image.png
Views:	119
Size:	17.6 KB
ID:	497921

            Click image for larger version

Name:	image.png
Views:	116
Size:	34.0 KB
ID:	497922

            thx

            Comment

            • kyus
              Senior Member
              • Feb 2024
              • 172

              #7
              Can you show the configuration of the item that is returning the error? Since it is a dependent item, what is it's master item... If you want to fetch data with it using the token, you should be using a different item type, probably HTTP...

              Comment

              • focar
                Junior Member
                • Dec 2023
                • 17

                #8
                Master item:

                Name: Token Bearer Fetch
                Type: HTTP agent
                Key: api.token.fetch
                Type: text
                URL: https://{HOST.IP}/management/v1/oauth2/token
                Request Type: POST
                Request Body: JSON data
                {
                "grantType": "password",
                "userId": "zabbix",
                "password": "password",
                "scope": "..."
                }
                Interval 2h

                This works as i receive the info:
                Click image for larger version  Name:	image.png Views:	11 Size:	54.5 KB ID:	497963




                Discovery rule:
                Name: Set Bearer Token
                Type: Dependant Item
                Key: api.token.set
                Master Item: Token Bearer Fetch

                LLD: {#EXTOKEN} --> $.access_token


                Gives me this:

                Click image for larger version  Name:	image.png Views:	11 Size:	14.7 KB ID:	497964










                Attached Files
                Last edited by focar; 28-01-2025, 10:03.

                Comment

                • kyus
                  Senior Member
                  • Feb 2024
                  • 172

                  #9
                  Oh, so the error is in the discovery rule. Well, this looks like $.access_token isn't extracting the value of the received JSON, you could try:
                  Code:
                  $..access_token
                  but the expression really depends on the format of the received JSON.

                  Comment

                  • focar
                    Junior Member
                    • Dec 2023
                    • 17

                    #10
                    yeah, already tried different JSONpaths... no worky.

                    i'll see how i can move forward in this.

                    thanks for your feedback.

                    Comment

                    Working...