You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.
Table of Contents

6 Expression macros

Overview

Expression macros are useful for formula calculations. They are calculated by expanding all macros inside and evaluating the resulting expression.

Expression macros have a special syntax:

{?EXPRESSION}

The syntax in EXPRESSION is the same as in trigger expressions (see usage limitations below).

{HOST.HOST<1-9>} and {ITEM.KEY<1-9>} macros are supported inside expression macros.

Usage

In the following locations:

  • graph names
  • map element labels
  • map shape labels
  • map link labels

only a single function, from the following set: avg, last, max, min, is allowed as an expression macro, e.g.:

{?avg(/{HOST.HOST}/{ITEM.KEY},1h)}

Expressions such as {?last(/host/item1)/last(/host/item2)}, {?count(/host/item1,5m)} and {?last(/host/item1)*10} are incorrect in these locations.

However, in:

  • trigger event names
  • trigger-based notifications and commands
  • problem update notifications and commands

complex expressions are allowed, e.g.:

{?trendavg(/host/item1,1M:now/M)/trendavg(/host/item1,1M:now/M-1y)*100}

When using expression macros in templates please do not specify the template name but rather use {HOST.HOST<N>}, because template names are not substituted with hosts during linkage. You can also omit host reference altogether for the first host, e.g. {?avg(//item1,1h)}

See also:

  • Supported macros for a list of supported locations of the expression macro
  • Example of using an expression macro in the event name