Zabbix 2.4 features, part 5 – Custom action condition formula

In Zabbix versions before 2.4, notification (action) conditions were limited to three predefined options – “AND”, “OR”, “AND/OR”. Zabbix 2.4 adds a new option - Custom expression. This results in full freedom when deciding how all the different conditions should be handled.

Articles in 2.4 feature series:

Current action condition types

In Zabbix 2.2, calculation type dropdown in action conditions looked like this:

The options allowed to interpret conditions in 3 different ways:

  • AND – all conditions had to apply
  • OR – it was enough for one condition to apply
  • AND/OR – Zabbix automatically derived a formula where conditions of the same type were grouped, and any one of them had to apply – and then all groups had to apply

The last one might seem a bit unclear – an example could help. If the conditions would be as follows:

  • Trigger: Apache not running
  • Trigger: memcached not running
  • Host group: Production

Using the “AND/OR” calculation type will make this action fire if a host is in the “Production” group, and the trigger that generated the event is either about Apache not running, or memcached not running.

But what we would like to have is conditions like these:

  • Trigger: Apache not running
  • Trigger: memcached not running
  • Host group: Production
  • Host group: Customer relation management application

In this case we would like to react if it’s one of the triggers and host belongs to both groups – essentially, making the desired formula (Trigger_1 OR Trigger_2) AND Group=Production AND Group=CRM. This would require having one group of conditions using OR, another using AND – there was no way to configure such conditions in Zabbix 2.2.

Custom expression for action conditions

The same dropdown in 2.4 looks like this:

Notice the Custom expression entry? That’s the powerful one. Let’s take our previous condition example that we could not configure in Zabbix 2.2 and identify individual entries with letters – just like Zabbix would do.

  • (A) Trigger: Apache not running
  • (B) Trigger: memcached not running
  • (C) Host group: Production
  • (D) Host group: Customer relation management application

With the new functionality we would choose Custom expression and then write in the input field:

(A or B) and C and D

And that’s it, done. You may also check the introduction of this feature in the What’s new section in the Zabbix manual, as well as full documentation on action conditions.

Relation to LLD

If you have followed our previous posts on the upcoming 2.4 features, you might recall that this appeared in the improved LLD filtering first, discussed in part 1 – multiple LLD filters. During the development of that feature the need for a custom formula in LLD filtering was apparent. Once it was developed there, it was easier to port it over to actions.

This entry was posted in Technical and tagged . Bookmark the permalink.

Leave a Reply