Επεξεργασία

Κοινή χρήση μέσω


Alert on Telemetry

If something happens in your environment or app that you need to act on, you can set up a system that sends you an alert. Azure Application Insights makes it easy to define such alerts.

You can use the following tools to define and set up alerts on telemetry events:

  • Power BI metrics (if you use the Power BI app on telemetry data)
  • Azure Application Insights Alerts
  • Azure Logic Apps
  • Power Automate

Use the Power BI Metrics approach if you want a no-code experience and if you do not have any experience with the KQL language.

For the latter three approaches, you need a Kusto (KQL) query to define the alerting condition.

No-code alerting with Power BI Metrics

If you use the Power BI app on telemetry data, it's very easy to track the metrics that are important to you.

With metrics in Power BI, you can curate your own metrics and track them against key business objectives, in a single pane. This feature enhances data culture by promoting accountability, alignment, and visibility for teams and initiatives within organizations.

Follow this simple four-step process to setup alerting with Power BI Metrics:

  1. First, you need to create a scorecard in the Power BI service. See Create scorecards in Power BI.
  2. Then simply add the metrics you want to track by connecting to your Power BI report on telemetry. See Create connected metrics.
  3. To add alerting, define status rules for your metrics. This will automate status updates based on rules that govern that metric. Rules trigger changes based on value, percentage of target met, date conditions, or a combination of the three, making the rules as versatile as possible. For connected metrics, these status rules are refreshed every time the data in your scorecard is refreshed. For more information, see Create automated status rules for metrics.
  4. Finally, follow metrics to get alerts in Teams or by email. See Follow your metrics.

For more information about Power BI Metrics, see Get started with metrics in Power BI.

Low-code alerting with KQL

When defining an alert based directly on telemetry, you need to define two things:

  1. A Kusto (KQL) query that defines the alerting condition. It's considered good practice to add a where clause that limits the timestamp of events in the query, for example, | where timestamp > ago(1h).
  2. How often you want to run the alerting query. Typically, the recurrence follows the where clause in the alerting query. For example, if the query looks back 1 hour, then you set your recurrence to 1 hour as well.

Tip

Samples of alerting queries are shared by Microsoft and third parties on the Business Central BCTech repository on GitHub. You can also share your alerting queries with the community on GitHub.

Create alerts in Azure Application Insights

If you want to create alerts in Azure Application Insights, then do as follows:

  1. Open the Azure portal and locate your Application Insights resource.
  2. In the navigation pane on the left, select Alerts.
  3. Add a KQL alerting condition query in the condition for a custom log search.

To read more about Azure Monitor alerts, go to Azure Application Insights in the Azure documentation.

Create alerts using Azure Logic Apps and Power Automate

Azure Logic Apps and Power Automate have built-in connectors to query telemetry in Azure Application Insights for setting up custom notifications or automating certain actions that are triggered by an environment's lifecycle event.

Note

Samples of custom notifications and automations are shared by Microsoft and third parties on the Business Central BCTech repository on GitHub. You can also share your Application Insights Alerts and Automations with the community on GitHub.

The samples below can help getting started with customization and automation using Application Insights.

Important

Deploying a Logic App to Azure also creates the API Connection Resources necessary to authenticate certain actions in the Logic Apps.

After deploying the Logic App, navigate to the created API Connection Resources in the Azure Portal to authenticate them. The Application Insights API Connection Resource can be authenticated using the Application ID and an API Key. These can be found and generated on the API Access page of the Azure Application Insights resource in the Azure Portal.

If you have already have API Connection Resources deployed in the selected Resource Group for the connections needed to run the Logic App you can reuse them by entering the same resource name before deploying the Logic App.

Example - Run an alerting query every "n" days and send an email

This Logic App runs every number of days (specified in app deployment). It lists all updates made available to environments that emit telemetry to the specified Application Insights resource during the period. Administrators can use this app to replace email notifications they'd receive for environments when set up as notification recipient.

Deploy to Azure

Example - Run an alerting query every "n" minutes and send a message to Teams

This Logic App queries Application Insights every number of minutes (specified in app deployment). It notifies a user (also specified in deployment) of any deleted environments in Microsoft Teams. The action that sends the notification in Teams can be updated to notify a Channel or Group Chat instead.

Deploy to Azure

Telemetry overview
Enabling telemetry
Available telemetry
Telemetry FAQ