Ad Widget

Collapse

Discovery rule coming from JSON creates duplicate items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • carles
    Junior Member
    • Oct 2024
    • 7

    #1

    Discovery rule coming from JSON creates duplicate items

    Hi,

    I'm writing here after hours of debugging, hoping someone can help me.

    I'm using Proxmox VE and Zabbix 7.0. I've started using the official template, which uses Proxmox API, but it lacks some items like ZFS pools status, so I've started creating a new template (also using Proxmox API) to get that information. I've managed to get a JSON with the information I'm interested into, but I'm struggling with Discovery rule + Item Prototype.

    The new template has the following:
    Master Item: Get ZFS Pools
    Click image for larger version

Name:	Master Item.png
Views:	272
Size:	39.4 KB
ID:	492046
    URL: https://{$PVE.URL.HOST}:{$PVE.URL.PORT}/api2/json/nodes/{$PVE.NODE}/disks/zfs

    I associated this master item to a host, and it returns the following JSON:

    Code:
    {
       "data":[
          {
             "alloc":3155472384,
             "health":"ONLINE",
             "size":33285996544,
             "free":30130524160,
             "frag":10,
             "dedup":1,
             "name":"rpool"
          },
          {
             "frag":0,
             "dedup":1,
             "free":10200104960,
             "name":"vmstorage-local",
             "alloc":442368,
             "size":10200547328,
             "health":"ONLINE"
          }
       ]
    }
    I would like to get the name of each item with its health.

    I've created a Discovery Rule + Item Prototypes as dependent items of Get ZFS Pools.
    Discovery rule: ZFS Pool Discovery
    Click image for larger version

Name:	ZFS Pool Discovery.png
Views:	148
Size:	34.6 KB
ID:	492047
    With LLD Macros to discover each storage and its health
    Click image for larger version

Name:	ZFS Pool Discovery Macros.png
Views:	151
Size:	21.6 KB
ID:	492048

    Item Prototype: ZFS Pool [{#ZFS.POOL.NAME}] health
    Click image for larger version

Name:	Item Prototype def.png
Views:	154
Size:	58.7 KB
ID:	492050


    I've checked JSON Paths using https://jsonpath.com/ and everything seems OK to me. Despite of that, I get the following error:
    Click image for larger version

Name:	Cannot create item.png
Views:	156
Size:	20.5 KB
ID:	492049

    To me, it seems that MACROS with the pool name are not being passed correctly to the Item prototype. Zabbix logs show:

    Code:
    82569:20240930:174725.654 In zbx_substitute_lld_macros() data:'$.data[?(@.name=="{#ZFS.POOL.NAME}")].health'
    82569:20240930:174725.654 cannot substitute macro "{#ZFS.POOL.NAME}": not found in value set
    82569:20240930:174725.654 End of zbx_substitute_lld_macros():SUCCEED data:'$.data[?(@.name=="{#ZFS.POOL.NAME}")].health'
    Of course, the host has only this template and has no items. I even recreated the host a few times.

    I would be extremely grateful if someone could point me in the right direction.

    Cheers,
    Carles
Working...