[comment]: # translation:outdated

[comment]: # ({5e06cf30-b9198e3b})
# 5 表达式宏

[comment]: # ({/5e06cf30-b9198e3b})

[comment]: # ({9927cbe0-e27300f7})
#### 概述

表达式宏对于公式计算很有用。 它们是通过展开内部的所有宏并评估结果表达式来计算的。

表达式宏有一个特殊的语法：

 · {?EXPRESSION}

{HOST.HOST<1-9>} 和 {ITEM.KEY<1-9>} 宏在表达式宏中受支持。 从 Zabbix 6.0.9 开始，表达式宏中支持 {ITEM.KEY<1-9>} 宏。

[comment]: # ({/9927cbe0-e27300f7})

[comment]: # ({2295d623-16162d7f})
#### 用法

在以下位置：

  · - 图表名称
  · - 地图元素标签
  · - 地图形状标签
  · - 地图链接标签

只有来自以下集合的**单个**函数：`avg`、`last`、`max`、`min` 允许作为表达式宏，例如：

  · {?avg(/{HOST.HOST}/{ITEM.KEY},1h)}
  ·
诸如`{?last(/host/item1)/last(/host/item2)}`、`{?count(/host/item1,5m)}` 和`{?last(/host/item1)* 10}` 在这些位置不正确。

然而，在：

  · - 触发事件名称
  · - 基于触发器的通知和命令
  · - 问题更新通知和命令
  ·
**复杂**表达式是允许的，例如：

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

也可参见：

- · [Supported macros](/manual/appendix/macros/supported_by_location) 获取表达式宏的支持位置列表
- · [Example](/manual/config/triggers/expression#example_17) 在事件名称中使用表达式宏

[comment]: # ({/2295d623-16162d7f})
