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

API/item.get: macros sometimes not expanded in item names

    XMLWordPrintable

    Details

    • Type: Incident report
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.0.31
    • Fix Version/s: None
    • Component/s: API (A)
    • Labels:
      None
    • Environment:
      Production

      Description

      sometimes, macros are not expanded in item names while returning an API call (item.get).

      -> [sometimes] means:

      • When the macro exists in the host but not on the template:
        • The item name in the API call resut is complete: macro is expanded

      example :

      "item": "dummy_hostmacro_{$HOSTMACRO}"

      "name": "dummy_hostmacro_something - HOST"

      • When the macro is inherited from the template, and the value is overwritten at host level (called "change" in Zabbix GUI):
      • the macro gets expanded

      example:

      "item": "dummy_templatemacro2_{$TEMPLATEMACRO2}"

      "name": "dummy_templatemacro2_overwrite"

      • When the macro exists in the template but the value is not overwritten at host level :
        • Macro not expanded

      "item": "dummy_templatemacro1_{$TEMPLATEMACRO1}"

      "name": "dummy_templatemacro1_{$TEMPLATEMACRO1}"

      Note: When there is a combination of macros in the item names, they are expanded according to the same rule. For instance:

      The macro {$AM_STAGE} is a template macro but is overwritten at host level. Therefore it gets expanded. The other macros ({$LOGDIR_NET}, {$AVA2GAINFEED_INSTR})

      I have not tested if the same problem applies to LLD.

       

       


      Full trace below


       

      {
      	"xhrStatus": "complete",
      	"request": {
      		"method": "POST",
      		"url": "api/datasources/proxy/1",
      		"data": {
      			"jsonrpc": "2.0",
      			"method": "item.get",
      			"params": {
      				"output": [
      					"name",
      					"key_",
      					"value_type",
      					"hostid",
      					"status",
      					"state"
      				],
      				"sortfield": "name",
      				"webitems": true,
      				"filter":
      
      				{
      					"value_type": [0, 3]
      				},
      				"selectHosts": [
      					"hostid",
      					"name"
      				],
      				"hostids": [
      					"13583"
      				]
      			},
      			"id": 1,
      			"auth": "04692a48c0fff374501aae40d0fb4545"
      		}
      	},
      	"response": {
      		"jsonrpc": "2.0",
      		"result": [{
      				"itemid": "323345",
      				"name": "dummy_hostmacro_something - HOST",
      				"key_": "system.run[\"echo 0\"]",
      				"value_type": "3",
      				"hostid": "13583",
      				"status": "0",
      				"state": "0",
      				"hosts": [
      
      					{
      						"hostid": "13583",
      						"name": "AM_APP-GAINDV1-VMR"
      					}
      				],
      				"item": "dummy_hostmacro_{$HOSTMACRO}"
      			},
      			{
      				"itemid": "323350",
      				"name": "dummy_templatemacro1_{$TEMPLATEMACRO1}",
      				"key_": "system.run[\"echo 1\" ]",
      				"value_type": "3",
      				"hostid": "13583",
      				"status": "0",
      				"state": "0",
      				"hosts": [
      
      					{
      						"hostid": "13583",
      						"name": "AM_APP-GAINDV1-VMR"
      					}
      				],
      				"item": "dummy_templatemacro1_{$TEMPLATEMACRO1}"
      			},
      			{
      				"itemid": "323355",
      				"name": "dummy_templatemacro2_overwrite",
      				"key_": "system.run[\"echo 2\" ]",
      				"value_type": "3",
      				"hostid": "13583",
      				"status": "0",
      				"state": "0",
      				"hosts": [
      
      					{
      						"hostid": "13583",
      						"name": "AM_APP-GAINDV1-VMR"
      					}
      				],
      				"item": "dummy_templatemacro2_{$TEMPLATEMACRO2}"
      			}
      		],
      		"id": 1
      	}
      }
      

        Attachments

          Activity

            People

            Assignee:
            zabbix.support Zabbix Support Team
            Reporter:
            it.sdm itsdm
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: