-
Type:
Incident report
-
Resolution: Fixed
-
Priority:
Trivial
-
None
-
Affects Version/s: 3.0.31
-
Component/s: API (A)
-
None
-
Environment:Production
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:
- "item": "FileCount_in_{$AM_STAGE}////{$AVA2GAINFEED_INSTR}" class="external-link" target="_blank" rel="nofollow noopener">\\{$LOGDIR_NET}\\{$AM_STAGE}\\\\{$AVA2GAINFEED_INSTR}"
- "name": "FileCount_in_DEV////{$AVA2GAINFEED_INSTR}" class="external-link" target="_blank" rel="nofollow noopener">\\{$LOGDIR_NET}\\DEV\\\\{$AVA2GAINFEED_INSTR}"
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
}
}