[ZBXNEXT-5369] Macro like {EVENT.TAGS} that expands to JSON format Created: 2019 Aug 14  Updated: 2024 Apr 10  Resolved: 2020 Mar 28

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Server (S)
Affects Version/s: 3.0.28, 4.2.5
Fix Version/s: 5.0.0alpha4, 5.0 (plan)

Type: Change Request Priority: Minor
Reporter: Larry Dorman Assignee: Aleksejs Sestakovs
Resolution: Fixed Votes: 5
Labels: macros
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

n/a


Issue Links:
Duplicate
is duplicated by ZBXNEXT-5735 An option to get event tags as struct... Closed
Team: Team C
Sprint: Sprint 62 (Mar 2020)
Story Points: 0.25

 Description   

It would be nice if there were a macro like {EVENT.TAGS} that exports the data in JSON format.  I've managed to work around this by creating all of my tags with quoted names and values and then being crafty in the output specification:   "eventTags" : [\{\{EVENT.TAGS}}]

What I've done is fragile, though as forgetting to quote the tag name and value will break the code consuming the data output.



 Comments   
Comment by Alexei Vladishev [ 2020 Feb 06 ]

It might be implemented using {{EVENT.TAGS}.json()} syntax so that in the future it could be extended to other formats if needed.

Comment by Alexei Vladishev [ 2020 Feb 06 ]

See also ZBXNEXT-5753, it talks about use of the macro in web hooks.

Comment by Glebs Ivanovskis [ 2020 Feb 06 ]

It might be implemented using {{EVENT.TAGS}.json()} syntax

I don't think this is a good idea. It will imply that there is a json() macro function which can be applied to any macro, but I guess it's not how it will be implemented. Instead of applying json() macro function to the value of {EVENT.TAGS}, implementation of {‍{EVENT.TAGS}.json()} will likely "cheat" using original even tag information. json() will only work in this specific case and it will be inconsistent with how other macro functions are implemented and used.

Comment by Alexei Vladishev [ 2020 Feb 07 ]

cyclone, I see what you mean but I still think that it is more consistent than multiplying number of macros just because we want output in a new format. It is doable in a nice way if we switch to representation of all macros in JSON format internally, for example.

Comment by Alexei Vladishev [ 2020 Mar 17 ]

After a few discussions we decided to give up the original idea of the json() function. The new macro will be called {EVENT.TAGSJSON}. Note that we already have {EVENT.TAGS.<TAG NAME>} therefore we couldn't use more obvious {EVENT.TAGS.JSON}.

It will be implemented in Zabbix 5.0.

Comment by Glebs Ivanovskis [ 2020 Mar 17 ]

I think you can expect a lot of "{EVENT.TAGS.JSON} resolves to *UNKNOWN*" bug reports if it is implemented like this, because it is so logical to put a dot there. I'm sure many users will do this mistake. Have you considered {EVENT.JSON.TAGS} or {JSON.EVENT.TAGS}?

Comment by Aleksejs Sestakovs [ 2020 Mar 27 ]

Available in versions:

Documentation updated:

Generated at Fri Apr 25 14:47:19 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.