How to setup an email alert for high Active Message count for Azure Service Bus Queue
How to setup an email alert for high Active Message count for Azure Service Bus Queue
![Image for post](https://miro.medium.com/max/1488/1*ZBleJ3hvkw6cby7N6giAmA.png)
Photo by Hugo Jehanne on Unsplash
This post assumes that you have an Azure service bus namespace setup with a Queue. Here is the official documentation for instructions.
I am going to use a service bus namespace AlertDemoServiceBus which has a queue named Orders.
Lets start!
Login to you account and navigate to the service bus namespace.
Click on Alerts and New Alert Rule
![Image for post](https://miro.medium.com/max/1034/1*KbM4c66qAH1z2P3RUGl7KQ.png)
This should open a new alert rule page. Here, we select the resource, which is our service bus namespace. If have only 1 service queue, then it should auto-populate.
Now, we have to set the condition for alert rule.
![Image for post](https://miro.medium.com/max/1522/1*S1VRyvwT3hgD_Z1nV59fbQ.png)
On click of select condition link, we get a new window in which we can setup the logic. We can setup alert on various signals as shown below but here we will using “Count of active messages in a Queue/Topics”
![Image for post](https://miro.medium.com/max/1498/1*w70rsYNW_g9g4mp5Oebp_w.png)
Once we select the base signal, on the next page we can configure the logic as below.
![Image for post](https://miro.medium.com/max/1700/1*rUbWb-QZUpGCFVqE4m27Yw.png)
Here I am setting alert on Orders Entity with threshold as 1000 active message and the condition will be checked every 5 mins.
Next would be the part where we setup actual Alert email when the condition is met. We have to create an Alert Group to achieve that. This takes us through a wizard.
First step would be to name it. I am creating an alert with a name HighCntAlert
![Image for post](https://miro.medium.com/max/1606/1*1aTj1ye6hTYgY0jz_1PIHw.png)
The next part would be setup notification.
Lets give it a name.
![Image for post](https://miro.medium.com/max/1662/1*T8DH_Vv6prh45J5KJFX-Fw.png)
And provide an email address to receive an alert
![Image for post](https://miro.medium.com/max/1416/1*h8B6sDJp7MElAEoSf9Nuyw.png)
As we can notice here, we can also request for an SMS or voice message but it attracts extra charges.
Once its setup, we can click review and create. It should create an alert group with email as a notification option for us.
The as below, give it a name and severity Level and enable it upon creation to start receiving alerts immediately .
![Image for post](https://miro.medium.com/max/1858/1*fqY406PXGlbZjCAir-FpRQ.png)
This should trigger a confirmation email.
![Image for post](https://miro.medium.com/max/1212/1*6bMycrpQLRatOYyWT6LNpQ.png)
Once its ready, we should be able to see it under “Manage Alert Rules” menu.
![Image for post](https://miro.medium.com/max/2914/1*8csW2DTo0b9Avc6o6LSwkg.png)
We are all setup!!
Now, when the queue count goes to 1000 as per our condition, Azure will create an alert. We can see this alert by navigating to “Alert” menu on the namespace.
We have to wait for 5 mins for azure to trigger the condition as we had configured in our rule above
After 5 mins, we can see an alert for Sev 2 raised for our queue in Alerts section of our service bus namespace.
![Image for post](https://miro.medium.com/max/3048/1*lfi8PxSFTaAZre1Ce2aMLw.png)
And an email sent to our registered email address from azure-noreply@microsoft.com
![Image for post](https://miro.medium.com/max/1068/1*6gU7LlC6c_uVm-L2wkeoDw.png)
In the details, notice the alert state.
![Image for post](https://miro.medium.com/max/3072/1*p2Lp3ihGM9tcGBSPicsPuQ.png)
Once the queue count goes down, the state automatically changes to Resolved
![Image for post](https://miro.medium.com/max/3086/1*NzE7MYXhzSIRj7HqBENsoQ.png)
and we also get an email notification about this progress.
![Image for post](https://miro.medium.com/max/1458/1*fSddAlFw8lQMwhTunfracQ.png)
Thank you!!