[ZBXNEXT-2841] Feature: Zabbix API *.get() calls to expand macros Created: 2015 Jun 05 Updated: 2020 Apr 21 |
|
Status: | Open |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | API (A) |
Affects Version/s: | 2.4.5 |
Fix Version/s: | None |
Type: | Change Request | Priority: | Trivial |
Reporter: | Lior Goikhburg | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 28 |
Labels: | macros | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Issue Links: |
|
Description |
Currently when using api .get() calls on items, triggres etc. the returned results contain raw (unexpanded) macros {$XXX}. This is meaningless outside of zabbix, and would be more useful if the results have the macros expanded. |
Comments |
Comment by Marc [ 2015 Jun 05 ] |
Well, expanding macros is already supported for some API methods - e.g. for trigger.get(). |
Comment by Lior Goikhburg [ 2015 Jun 08 ] |
Which version does support that ? { "status": "0", "description": "{$COMPONENT} Status URI HTTP Code", "state": "0", "url": "", "type": "0", "templateid": "17983", "lastchange": "1433361132", "value": "0", "priority": "3", "triggerid": "17992", "flags": "0", "comments": "", "error": "", "expression": "{22975}=1" } |
Comment by Lior Goikhburg [ 2015 Jun 08 ] |
I'm particularly interested in having macros expanded in item keys, but having macros expanded in all object properties would be even better. |
Comment by Marc [ 2015 Jun 08 ] |
zerthimon, regarding trigger.get() see corresponding API documentation and watch out for "expand*" method parameters. I understand that there might be a custom need to get macros of item key parameters resolved. Anyhow, from my personal pov this should probably not be part of this method. Such a edge case is likely better covered by resolving it in the custom application if needed. |
Comment by David [ 2015 Jun 16 ] |
I disagree, knowing what the macro value was at the time of data collection is very useful, particularly if it has ever been changed. Also, if you are archiving data elsewhere, the expanded key is more useful than a macro. I assume this is already being expanded in order to tell agents what the value is, can't this code be reused? From our testing, even host.get only returns expanded macros for macros set on the host, not ones inherited from templates. |
Comment by viktorkho [ 2015 Jun 30 ] |
In more wide case, it will be rigth to have possibility to "expand" macro's value in every place, where mocros can be used. Isn't it? What is the developers' reason to go in other way? |
Comment by Chris Christensen [ 2015 Oct 29 ] |
Agree (with David and viktorkho). There's also some precedent on external libs to try and manage this, like Zabbix2 Perl API client - and interesting note by the developers on this: "we are not expanding hostmacros or globalmacros, those are problematic". I think the implementation details of this are trapped inside the Zabbix application and should be properly supported via the API. |
Comment by Chris Christensen [ 2015 Oct 29 ] |
Another example of macro replacement challenges: https://github.com/alexanderzobnin/grafana-zabbix/pull/106 |
Comment by Aleksandrov Artyom [ 2016 May 17 ] |
It's may be really useful! In another case we should have expand method for every parameter which can has macros. For example there is no expandUrl method now but you can use macro there. |
Comment by Egon Burgener [ 2017 Mar 21 ] |
The same with tags results in trigger.get (selectTags set) |
Comment by richlv [ 2017 Sep 11 ] |
might be worth listing where expansion would be desired. please correct and expand as needed. trigger.get explicitly allows 3 fields to be expanded already :
items :
hosts :
|
Comment by James Cook [ 2020 Apr 21 ] |
Hi Richlv, Were suffering a fair bit with this. We use user macros a lot to allow configuration in templates that is controlled per host for example in template for PgBouncer port monitoring we have ITEM NAME - PgBouncer Port - Status ({$APP.PORT.CONF.NUMBER:"PgBouncer"}:tcp) On specific hosts we just override the macro '{$APP.PORT.CONF.NUMBER:"PgBouncer"}' with another port such as 7432 which requires no template change to monitor PgBouncer on a different port. We also have some SLA reporting which uses Zabbix data and this is affected in the same way. It would be nice for the API to perhaps have an option (ExpandMacros) which would be non breaking and this would replace all macros where ever you can set them in the object (Item/Trigger/Hosts etc...) We try to use user macros everywhere we can to enable template flexibility across several clients as they all have different needs and configurations. Cheers James |