2

I check if error occurred by checking whether the last value matches regexp.

({myhost.com:my.item.regexp(^ERROR$)})#0

I need some tolerance by checking not last but last N values to match the regexp, i.e. last 2-3 values.

How can I achieve that?

odiszapc
  • 151
  • 1
  • 2
  • 6

2 Answers2

3

According to Zabbix function documentation, function regexp() accepts a second parameter - the number of seconds or values to analyze. Unfortunately, it will return 1 if at least one of the values matches, which is not what you need - you need all values to match.

Therefore, if your regular expression is simple enough, consider using count() function with "eq" or "like" operators:

{host:item.count(#3,ERROR,eq)} = 3
{host:item.count(#3,ERROR,like)} = 3

There is also a feature request to be able to use regular expressions in count() function and it is tracked at ZBXNEXT-1250.

asaveljevs
  • 1,143
  • 6
  • 8
  • 1
    Since [Zabbix 3.2](https://www.zabbix.com/documentation/3.2/manual/appendix/triggers/functions) using `regexp` is possible, for example: `{myhost.com:my.item.count(#3,"^ERROR$","regexp")} = 3` – Jeroen Vermeulen - MageHost Dec 07 '16 at 22:03
0

Would something like

({myhost.com:my.item.regexp(^ERROR$).max(#3)}=0)

work for you? If not, just use the built-in trigger expression constructor in Zabbix web GUI, it makes this kind of stuff easier, if not easy.

Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81