Reputation: 1
I'm trying to create a new alert rule that will send an email every time a new dead letter appears in my topics in the service bus.
Initially, I tried searching for a solution at the subscription level so I could choose which subscriber to monitor for each topic, but I couldn't manage to set it up (is this possible? I tried querying). After that, I realized there is a default condition I can use, which triggers an alert whenever there are more than x dead letters (in my case, 1). This worked at first, but then I noticed that the alert triggers only once when the threshold is exceeded. For example, if I get a new dead letter (let's say the third one), it does not trigger another alert, even though (and because actually) the count is still above the threshold. Unfortunately, I can’t reset it immediately every time.
So: Is there a way to make the alert trigger for every single new dead letter? Is there a way to configure the rule at the subscription level rather than just at the topic level? Thank you very much!
Upvotes: 0
Views: 99
Reputation: 7818
It is not directly possible to create an alert or an alert rule when a message is dead lettered in a service bus queue or topic.
In order to create an alert rule when triggered, you can use either Service Bus Trigger in Azure Function
or a Logic App triggers
when a message is dead lettered in a service bus topic.
For now, there is an option for creating an alert rule to count the number of messages in a dead lettered topic or queue as shown below.
Go to Service Bus >> Monitoring >> Alerts >> Alert rules
After clicking on it, you can see below given screen for selecting the corresponding signal. Here it should be
Count of dead-lettered messages in a Queue/Topic
.
Once it's done, you can create a new action group for triggering the event or select any existing action group accordingly by adding an email notification details. After providing them, you can be able to create a new alert rule in the below way.
Another alternative could be writing a KQL query to meet your requirement and run it in Log Analytics workspace. Once the query gets executed as expected, you can click on alert rules and create it.
Sample KQL query:
AzureDiagnostics
| where ResourceType == "NAMESPACES"
| where EntityType_s == "Topic"
| project Resource, EntityName_s, TimeGenerated
Note: Change the EntityType_s
to /$DeadLetterQueue/Topic
for Dead lettered messages. As I do not have those kinds of messages in my environment, I have used the above sample query.
Reference SO on the relevant issue or requirement.
Upvotes: 0