How to get failed job queues directly on your mail?

When I was working for the end customer, one of the daily jobs for one of the consultants, was to check if all job queues in all databases and all companies were not stopped by some error.

I thought, why cannot we get the notification whenever the Job Queue is stopped? That would save us a lot of time.

What are the solutions?

Almost five years later this is still not a standard feature in Business Central. And apparently, we will not get it soon (Check this idea  Microsoft Idea · Job Queue failure notification (dynamics.com)

So what instead? I know the partners who try to solve this issue with custom development. Also, I have seen at least three apps on AppSource that solves the issue.

However, I believe that this should be a standard feature in Business Central and the customers should not pay for it (at least for the basic solution).

Is there any other option?

Let’s see if we can do something without (or with a minimum) AL development. 

The answer could be already hidden in the idea that I showed you above – the telemetry. But the problem, that the author pointed, is that the telemetry is only for the administrators. But is it? Can we use it somehow to send the notifications?

Telemetry Signal – AL0000E26

The Telemetry for Business Central allows getting information about the failed Job Queue Entries. You can get it with below KQL.

traces
| where customDimensions.eventId in (“AL0000E26”) and customDimensions.aadTenantId !in (“default”, “common”, “”) and
customDimensions.alJobQueueResult == “Fail”
| project [‘Date’] = timestamp, alJobQueueCompanyName = customDimensions.alJobQueueCompanyName,
alJobQueueExecutionTimeInMs = customDimensions.alJobQueueExecutionTimeInMs,
alJobQueueId = customDimensions.alJobQueueId,
alJobQueueObjectId = customDimensions.alJobQueueObjectId,
alJobQueueObjectType = customDimensions.alJobQueueObjectType,
alJobQueueResult = customDimensions.alJobQueueResult,
alJobQueueScheduledTaskId = customDimensions.alJobQueueScheduledTaskId,
alJobQueueStatus = customDimensions.alJobQueueStatus,
environmentName = customDimensions.environmentName,
environmentType = customDimensions.environmentType

You can send the mail using the Alerts in Application Insights but I am aware that is more technical and not everyone has access there. 

Power Automate Flow

Instead of that, I want to propose an easy Power Automate Flow. The flow would allow you to send notifications to anyone in the way you need – mail, Teams, or even WhatsUp message. Application Id and Access Key are the only things that you need to connect to Application Insights.

Import the Flow

You can download the flow here and import it to your Power Automate. Please remember that Application Insights requires a premium connector.

How does it work?

We will run the query every 1 hour, however, you can set your recurrence (for example every 15 min).

Then, for a more comfortable setup, we will initialize the Email parameters such as Address (use “;” to send messages to more people – for example, consultant or customer), Subject, and Body.

In the last section, we will set Signals and KustoQuery. You do not need to change anything here if you do not know the KQL.

Later flow checks if there are any records and cancel the flow if there is nothing. If any record has been found then the mail is sent. You can add also other notifications if needed.

Works…

… but I cannot see the error message. That is true. Some time ago I spoke with Microsoft people and the error message can contain GDPR sensitive data. This is the reason why in the telemetry signal we cannot have error text. To be honest, I hope this state will change soon with plans for new telemetry signals in April 2022. 

If not let me know if you want to do more – get an error message or even automatically restart the queue.   

5 Comments

Leave a Reply to Kris Cancel reply

Your email address will not be published.