RedditPP Mascot

RedditPP

r/zabbix • … • u/NMi_ru

Zabbix 6: Previous Value in message template

Hi, fellow zabbix masterminds,

In Zabbix 5 I've had the following message template showing the change of a value:

`Value: {{HOSTNAME}:{ITEM.KEY}.prev()} → {{HOSTNAME}:{ITEM.KEY}.last()}`

However, this was deprecated with the release of Zabbix 6:

[https://www.zabbix.com/documentation/6.0/en/manual/introduction/whatsnew600#simple-macros-replaced-by-expression-macros](https://www.zabbix.com/documentation/6.0/en/manual/introduction/whatsnew600#simple-macros-replaced-by-expression-macros)

Now that I've created a fresh Zabbix 6 installation (6.2.1-1), I'm struggling with the notification messages. The documentation is pretty confusing:

[https://www.zabbix.com/documentation/6.2/en/manual/config/notifications/action/operation/macros](https://www.zabbix.com/documentation/6.2/en/manual/config/notifications/action/operation/macros)

Example 2 -- Processor load is: last(/zabbix.zabbix.com/system.cpu.load\[,avg1\] -- yields just the same text.

Example 3 -- Latest value: last(/{HOST.HOST}/{ITEM.KEY}) -- shows the text with the {} stuff replaced with the hostname and the key, like this: Latest value: last(/virtualtest.001.nmi.ru/trapperitem1)

I've had a bit of luck with the new "{?" syntax: when I manually type the item key, I see that it works like intended:

`Value1: {?last(//trapperitem1,#1)}`

`Value2: {?last(//trapperitem1,#2)}`

`Value1: 114`

`Value2: 0`

​

However, when I try to use the {} placeholders for the item key -- no dice:

​

`ITEM.KEY=[{ITEM.KEY}]`

`Value1: {?last(//{ITEM.KEY},#1)}`

`Value2: {?last(//{ITEM.KEY},#2)}`

​

`ITEM.KEY=[trapperitem1]`

`Value1: *UNKNOWN*`

`Value2: *UNKNOWN*`

What am I missing?

P.S. I would really like to use something like the "previous value of {EVENT.OPDATA}" instead of the "last" that works for the first trigger item only, but I can't find it in the docs.

— 0