Not getting Email notification though threshold is crossed

My Requirement is to just to send a mail notification only when the condition is met(threshold is breached).

Every hour a test case runs in our Automation Tool, Its status will be either “Passed” or “Failed”, These status details(Passed/Failed) are present in PostgreSQL Database and this is coming to Grafana from PostgreSQL.

In Grafana we show only “Failed” status graph, like It shows Dot in the graph when the status is Failed for that particular Hour as shown below:


Now Our requirement is to Trigger a Email Notification when only continuously 3-Times status is “Failed”.

For example… in the above Graph:

In the Graph you can see the Status is “Failed” continuously at 1AM,2AM and 3AM.
Now the Mail Notification should be sent. However it is not happening.

Please find My query below:

Generated SQL for the above:
floor(extract(epoch from creation_time)/3600)*3600 AS “time”,
state AS metric,
count(actual_status) AS “actual_status”
FROM grafana_table
creation_time BETWEEN ‘2020-09-02T00:00:00Z’ AND ‘2020-09-02T22:35:33.85Z’ AND
state = ‘Failed’ AND
process_key = ‘Test case1’

This is how I have entered details in Alert section:

The Mail Notification is not being triggered. Am I missing something? Is my condition written correctly?

Sometimes it used to send mail with “No data” and “Ok”. So As I didn’t want mails for “No Data”, I selected “Keep Last State” in No Data section.

I DONT want Email Notification to be sent for “No Data”. I just want Email Notification sent saying “Alerting” when the Condition is met(threshold is breached).

All the SMTP settings are fine, few mails were already triggered. So SMTP settings is not an issue.

It would be really great if someone helps on this.