Ad Widget

Collapse

using arrays in JSON for LLD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Robot
    Junior Member
    • Apr 2018
    • 3

    #1

    using arrays in JSON for LLD

    Hello!
    I am trying to use a json file to create custom macroses.

    Code:
    {
        "data": [{
            "{#CISCOIP}": "ip",
            "{#CISCONAME}": "hostname",
            "{#USERS}": [{
                    "{#USERNAME}": "username1"
                },
                {
                    "{#USERNAME}": "username2"
                },
                {
                    "{#USERNAME}": "username3"
                }
            ]
        }]
    }
    JSON is valid, ldd works, operating to {#CISCOIP} and {#CISCONAME} works, but how to operate to #USERS fields? I tried something like {#USERS.#USERNAME} without succes. Is it even supported by zabbix?
    thx for help.
    Last edited by Robot; 19-04-2018, 11:32.
  • afritsch
    Junior Member
    • Jan 2019
    • 2

    #2
    I know this post is almost 1 year old, but I'm facing the same exact situation and for now I can't find an answer to this question anywhere.

    Comment

    • afritsch
      Junior Member
      • Jan 2019
      • 2

      #3
      After some more digging I found this thread: https://support.zabbix.com/browse/ZBXNEXT-1527

      The way to do it is have you JSON like this:

      Code:
       {    
      "data": [        
      {"{#CISCOIP}": "ip", "{#CISCONAME}": "hostname","{#USERNAME}": "username1"},
      {"{#CISCOIP}": "ip", "{#CISCONAME}": "hostname","{#USERNAME}": "username2"}, 
      {"{#CISCOIP}": "ip", "{#CISCONAME}": "hostname","{#USERNAME}": "username3"}, 
      {"{#CISCOIP}": "ip2", "{#CISCONAME}": "hostname2","{#USERNAME}": "username1"}    
      ]
      }
      The caveat: your Item Prototype Key *must* include {#CISCOIP}, {#CISCONAME} and {#USERNAME}, otherwise Zabbix won't resolve all macros and will complain about duplicate items.

      You will need something like:

      usernamekey[{#CISCOIP},{#CISCONAME},{#USERNAME}]

      You will probably be ok with

      usernamekey[{#CISCOIP},{#USERNAME}]

      since I believe you don't have more than one hostname per device.

      Comment

      • DCEM
        Junior Member
        • Feb 2020
        • 2

        #4
        I ended up posting in the wrong thread, but cannot delet it it seems, sorry about that

        Comment

        Working...