Ad Widget

Collapse

Zabbix 6: Previous Value in message template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander Javoronkov
    Junior Member
    • Aug 2022
    • 4

    #1

    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...ression-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...eration/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.


  • makini
    Member
    • Jul 2006
    • 59

    #2
    This works in v6.2.3 - prints previous value (e.g. in an Action message):
    Code:
    {?last(/{HOST.HOST}/{ITEM.KEY1},#2)}

    Comment

    • Alexander Javoronkov
      Junior Member
      • Aug 2022
      • 4

      #3
      Originally posted by makini
      This works in v6.2.3 - prints previous value (e.g. in an Action message):
      Code:
      {?last(/{HOST.HOST}/{ITEM.KEY1},#2)}
      Unfortunately I am unable to get it to work.

      The path where the message is:
      Administration / Media types / Telegram / Message templates / Problem

      My action message is:
      Code:
      Test=[{?last(/{HOST.HOST}/{ITEM.KEY1},#2)}]

      Zabbix 5 says:
      Code:
      Test=[{?last(/realhostname.001.gpucloud.ru/memory.pused,#2)}]

      Zabbix 6 says:
      Code:
      Test=[*UNKNOWN*]

      Comment

      • Alexander Javoronkov
        Junior Member
        • Aug 2022
        • 4

        #4
        I have some success after the zabbix-server upgrade:

        Zabbix server: Version has changed (new version: 6.2.3) / 3s
        → 6.2.3
        Test=[6.2.2]

        The previous test (shutting down the zabbix-agents) is working now as well:
        Test=[0]

        Is the difference between 6.2.2 and 6.2.3 that drastic? Hmm…

        Comment

        Working...