Problem:
Trigger send an e-mail immediately when the site is unreachable.
System:
Linux Debian Stretch, Zabbix 4.2.1.
Current configuration of the web scenario:
Scenario:
Name: website.com
Update interval: 30s
Attempts: 3
Agent: Zabbix
Steps:
(just one)
Name: website.com
URL: http://website.com/page.php
Follow redirects: checked
Timeout: 30s
(rest unchanged)
Current configuration of the trigger:
Name: The website.com can't be reached!
Expression: {VIRTUALMACHINE:web.test.fail[website.com].last(3m)}>0
(rest unchanged)
Explanation
The trigger has to send an e-mail if the site is unreachable for 3 minutes (or 3 last checks with timeout 30 seconds on every check). I was trying to do it in many ways (below*), but with each trigger expression that I tried the e-mail notification was sent immediately when the zabbix detected the problem for the first time (and not for the nth attempt).
*
{VIRTUALMACHINE:web.test.fail[website.com].sum(#3)}>0
{VIRTUALMACHINE:web.test.fail[website.com].last(3m)}<>0
{VIRTUALMACHINE:web.test.rspcode[website.com,website.com].last(0)}#200
{VIRTUALMACHINE:web.test.fail[website.com].last(3)}#0
{VIRTUALMACHINE:web.test.fail[website.com].sum(#3)}>0
{VIRTUALMACHINE:web.test.fail[website.com].last(3)}>0
{VIRTUALMACHINE:web.test.fail[website.com].min(1)}>0
Please if you give an answer explain it. Feel free to ask.
Solution/Workaround
I added tags on each trigger and I edited an e-mail actions by adding tag conditions.
For example:
(rest unchanged)
(rest unchanged)
Now Zabbix will send me a message 3 minutes after detecting that the website is down and If the problem will be resolved during these 3 minutes Zabbix won't send an e-mail.
Item
web.tyest.fail
returns the failed step of the scenario. Given that, you can achieve the desired result like this:This will check the last 3 values and alert if they all are above 0 (failures). Consider this scenario:
A few additional notes on the expressions you tried:
3
and3m
that you used for functionlast()
were ignored.1
that you used for function minmin()
means seconds, thus that trigger expression would mostly not work at all.