Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-20579

No macro expansion in Template > Discovery rule > Item Prototype

XMLWordPrintable

      Hi there,

      I want to create a discovery rule and items based on a JSON file. The file looks like this:

       

      [
         {
            "service":"app1",
            "status":"running"
         },
         {
            "service":"app2",
            "status":"running"
         },
         {
            "service":"app3",
            "status":"running"
         }
      ]

       

      Based on that I and to create an item for each service which returns the status.

      I made those steps:

      1. Created item in template to get the JSON data
      2. Created discovery rule
        • Type: "Dependent item" from the item in 1.
        • No preprocessing
        • LLD macros:
          • {{ {#SERVICENAME}

            > $[*].["service"]}}

          • {{ {#STATUS}

            }}> ${{[*].["status"]}}

        • No Filters
      3. Created Item prototype
        • Name: [Discovery] Status {#SERVICENAME}
        • Type : "Dependent item" from the item in 1.
        • Key: something{#SERVICENAME}
        • Preprocessing: JSONPath:
          • $..[?(@.service == '\{#SERVICE}')].status

      Now after this is done, I would expect to get something like

      • [Discovery] Status app1
        • Key: something[app1]
        • Result: ["running"]
      • [Discovery] Status app2
        • Key: something[app2]
        • Result: ["running"]
      • [Discovery] Status app3
        • Key: something[app3]
        • Result: ["running"]

       

      But it doesn't work because the item prototype isn't expanding the macros. This is what I get as error in the Discovery rules tab in the host:

      So why is it not expanding my macros?

       

      I was already searching for that problem and I already find related problems with "Zabbix trapper" items - but it does not apply here

        1. image-2022-02-15-08-14-35-213.png
          9 kB
          Tobias Großmann
        2. image-2022-02-17-18-05-04-916.png
          13 kB
          Aleksandrs Petrovs-Gavrilovs

            agavrilovs Aleksandrs Petrovs-Gavrilovs
            grossmaul Tobias Großmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: