[comment]: # ({b1624dc4-b1624dc4})
# 4 Using macros in messages

[comment]: # ({/b1624dc4-b1624dc4})

[comment]: # ({6d91e5d3-72998395})
#### Overview

In message subjects and message text you can use macros for more
efficient problem reporting.

In addition to a number of built-in macros, [user macros](/manual/config/macros/user_macros)
and [expression macros](/manual/config/macros/expression_macros) are also supported.
A [full list of macros](/manual/appendix/macros/supported_by_location) supported by Zabbix is available.

[comment]: # ({/6d91e5d3-72998395})

[comment]: # ({e5ad63df-e5ad63df})
#### Examples

Examples here illustrate how you can use macros in messages.

[comment]: # ({/e5ad63df-e5ad63df})

[comment]: # ({102863de-102863de})
##### Example 1

Message subject:

    Problem: {TRIGGER.NAME}

When you receive the message, the message subject will be replaced by
something like:

    Problem: Processor load is too high on Zabbix server

[comment]: # ({/102863de-102863de})

[comment]: # ({763adfed-1344257c})
##### Example 2

Message:

    Processor load is: {?last(/zabbix.zabbix.com/system.cpu.load[,avg1])}

When you receive the message, the message will be replaced by something
like:

    Processor load is: 1.45

[comment]: # ({/763adfed-1344257c})

[comment]: # ({ea320b91-3713b8a5})
##### Example 3

Message:

    Latest value: {?last(/{HOST.HOST}/{ITEM.KEY})}
    MAX for 15 minutes: {?max(/{HOST.HOST}/{ITEM.KEY},15m)}
    MIN for 15 minutes: {?min(/{HOST.HOST}/{ITEM.KEY},15m)}

When you receive the message, the message will be replaced by something
like:

    Latest value: 1.45
    MAX for 15 minutes: 2.33
    MIN for 15 minutes: 1.01

[comment]: # ({/ea320b91-3713b8a5})

[comment]: # ({88afe91c-88afe91c})
##### Example 4

Message:

    http://<server_ip_or_name>/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}

When you receive the message, it will contain a link to the *Event
details* page, which provides information about the event, its trigger,
and a list of latest events generated by the same trigger.

[comment]: # ({/88afe91c-88afe91c})

[comment]: # ({d41797c6-d41797c6})
##### Example 5

Informing about values from several hosts in a trigger expression.

Message:

    Problem name: {TRIGGER.NAME}
    Trigger expression: {TRIGGER.EXPRESSION}
     
    1. Item value on {HOST.NAME1}: {ITEM.VALUE1} ({ITEM.NAME1})
    2. Item value on {HOST.NAME2}: {ITEM.VALUE2} ({ITEM.NAME2})

When you receive the message, the message will be replaced by something
like:

    Problem name: Processor load is too high on a local host
    Trigger expression: last(/Myhost/system.cpu.load[percpu,avg1])>5 or last(/Myotherhost/system.cpu.load[percpu,avg1])>5

    1. Item value on Myhost: 0.83 (Processor load (1 min average per core))
    2. Item value on Myotherhost: 5.125 (Processor load (1 min average per core))

[comment]: # ({/d41797c6-d41797c6})

[comment]: # ({0ee2664c-0ee2664c})
##### Example 6

Receiving details of both the problem event and recovery event in a
[recovery](/manual/config/notifications/action/recovery_operations)
message:

Message:

    Problem:

    Event ID: {EVENT.ID}
    Event value: {EVENT.VALUE} 
    Event status: {EVENT.STATUS} 
    Event time: {EVENT.TIME}
    Event date: {EVENT.DATE}
    Event age: {EVENT.AGE}
    Event acknowledgment: {EVENT.ACK.STATUS} 
    Event update history: {EVENT.UPDATE.HISTORY}

    Recovery: 

    Event ID: {EVENT.RECOVERY.ID}
    Event value: {EVENT.RECOVERY.VALUE} 
    Event status: {EVENT.RECOVERY.STATUS} 
    Event time: {EVENT.RECOVERY.TIME}
    Event date: {EVENT.RECOVERY.DATE}
    Operational data: {EVENT.OPDATA}

When you receive the message, the macros will be replaced by something
like:

    Problem:

    Event ID: 21874
    Event value: 1 
    Event status: PROBLEM 
    Event time: 13:04:30
    Event date: 2018.01.02
    Event age: 5m
    Event acknowledgment: Yes 
    Event update history: 2018.01.02 13:05:51 "John Smith (Admin)"
    Actions: acknowledged.

    Recovery: 

    Event ID: 21896
    Event value: 0 
    Event status: OK 
    Event time: 13:10:07
    Event date: 2018.01.02
    Operational data: Current value is 0.83

::: noteimportant
Separate notification macros for the original
problem event and recovery event are supported since Zabbix
2.2.0.
:::

[comment]: # ({/0ee2664c-0ee2664c})
