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

Can't use json attribute in LLD macro, added with javascript in preprocessing

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Cannot Reproduce
    • Icon: Trivial Trivial
    • None
    • 5.0.1
    • None
    • None
    • CentOS 8, MariaDB

      Steps to reproduce:

      1. Add HTTP agent item on template A, which calls json api which returns the following data
      [{"name":"DEVICE1"},{"name":"DEVICE2"}] 
      1. Add JavaScript preprocessing step with following code on the item defined above (which adds the groupname attribute to each of the elements in the json array returned above, from the {$ZABBIX_HOSTGROUP} macro):

       

      newValue = JSON.parse(value);
      var groupName = '{$ZABBIX_HOSTGROUP}';
      for (i = 0; i < newValue.length; i++)
      {
       newValue[i].groupname = groupName
      }
      return JSON.stringify(newValue);

       

      1. Add discovery rule on template A, with the following LLD macro (extracts the groupname we added above to the {$ZBXGRP}):
      2. Add host prototype to the discovery rule, while adding the {$ZBXGRP} macro to the "Group Prototypes"

      Result:
      The host prototype does not get assigned to the group, the preprocessing step works if i look in the "Latest Data" tab, so the problem is probably with the LLD macro, or the group prototypes
      Expected:
      The host prototype should be assigned to the hostgroup, as defined in {$ZBXGRP}

        1. image-2020-07-17-15-14-03-032.png
          image-2020-07-17-15-14-03-032.png
          2 kB
        2. image-2020-07-17-15-15-32-715.png
          image-2020-07-17-15-15-32-715.png
          4 kB
        3. screenshot-1.png
          screenshot-1.png
          14 kB
        4. screenshot-2.png
          screenshot-2.png
          36 kB
        5. screenshot-3.png
          screenshot-3.png
          2 kB

            neogan Andrei Gushchin (Inactive)
            Badri Daniel Badri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: