Macros with context not supported in script items params

XMLWordPrintable

    • Type: Problem report
    • Resolution: Unresolved
    • Priority: Trivial
    • None
    • Affects Version/s: 6.4.12
    • Component/s: None
    • None

      Steps to reproduce:

      1. On a host, create a macro: {$SENTRY_WARNING_THRESHOLD} with value 10
      2. On that same host, create a second macro: {$SENTRY_WARNING_THRESHOLD:"default-asp"} with value 15
      3. Create a discovery rule with 2 LLD macros #PROJECTNAME and #PROJECTSLUG, with the following item prototype:
        • Name: {#PROJECTNAME}: warning threshold
        • Type: Script
        • Key: sentry.project_warning_threshold{#PROJECTSLUG}
        • Parameters:
          • threshold: {#SENTRY.WARNING_THRESHOLD:"{#PROJECTSLUG}"}
        • Script:
          • console.warn(value);
            var obj = JSON.parse(value);
            return obj.threshold * ((new Date()).getHours() + 1);

      Result:
      When testing, the correct value is returned:

      Note that the macro value has been prepopulated correctly.

      The server log shows:

      1975570:20240312:190835.064 {"threshold":"15"} 

      However, Execute now the item and the server logs the wrong value:

       

      1975549:20240312:190845.067 {"threshold":"10"} 

      Expected:
      The server should receive 15 as the value in both cases. At the very least, testing and execution should result in the same value.

            Assignee:
            Zabbix Development Team
            Reporter:
            Mikael Peigney
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: