-
Type:
Incident report
-
Resolution: Won't fix
-
Priority:
Trivial
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Steps to reproduce:
- I need to filter Zabbix API Query result to return ONLY One concrete macro.
- From API documentation it looks like that would be possible by using selectMacro propery or Search filter.
- No matter what I've tried 100-500 different attempts, selectMacros always returns either ALL macros in Template or Empty Macros array.
- The Query:
curl --insecure -i -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"template.get","params":{"search":{"host":"Test Zabbix Api selectMacros Template","macro":"{$MACRO3}"},"output":["hostmacroid","macro","value"],"selectMacros":"extend"},"auth":"myId","id":1}' https://<IP>/api_jsonrpc.php
This returns ALL Macros, but that is not desired output:
{"jsonrpc":"2.0","result":[{"templateid":"10578","macros":[{"hostmacroid":"1857","hostid":"10578","macro":"{$MACRO1}","value":"Value1"},{"hostmacroid":"1858","hostid":"10578","macro":"{$MACRO2}","value":"Value2"},{"hostmacroid":"1859","hostid":"10578","macro":"{$MACRO3}","value":"Value3"}]}],"id":1}
- "limit":1 - also doesn't work in any JSON request block.
- "selectMacros":["1859"] - doesn't work. This always returns empty array.
{"jsonrpc":"2.0","result":[{"templateid":"10578","macros":[[],[],[]]}],"id":1}I don't want to keep all the macros in the buffer. Because there may be passwords in other Macros. Is it so that Zabbix API filtering for macros doesn't work ? a bug ?
"selectMacros":"1859" - doesn't work, this returns an empty array like this:
{"jsonrpc":"2.0","result":[{"templateid":"10578","macros":[]}],"id":1}
Result:
See screenshot...
See log file...
See memory dump...
Expected:
See screenshot....
See attached patch file...