Get essential Application Insights

Completed

Business Central emits telemetry data for various activities and operations on tenants. Whether running Business Central Online or On-premises, you can set up your tenants to send telemetry to Application Insights. Application Insights is a service hosted within Azure that gathers telemetry data for analysis and presentation.

Monitoring telemetry gives you a look at the activities and general health of your tenants. It helps you diagnose problems and analyze operations that affect performance.

Environment-level and app/extension-level telemetry

Telemetry in Business Central can be enabled on two different levels:

  • Environment-level telemetry

  • App/extension-level telemetry (for each app/extension installed)

When telemetry is enabled on the environment level, telemetry is emitted to an Azure Application Insights resource for gathering data on operations that happen on the environment.

Telemetry can also be enabled on a per-extension basis. Enabling telemetry is done by setting an Azure Application Insights connection string in the app's manifest (app.json file). At runtime, certain events related to the app/extension are emitted to the Azure Application Insights resource. This feature targets publishers of per-tenant extensions or Microsoft Marketplace apps. It gives extension publishers insight into usage of their apps/extensions and also allows them to find errors and performance issues before partners and customers report them.

Both online environments and on-premises instances can emit telemetry to Azure Application Insights.

What are Application Insights?

Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals. Use it to monitor your live applications. It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users do with your app. It's designed to help you continuously improve performance and usability. It works for apps on a wide variety of platforms including .NET, Node.js, Java, and Python hosted on-premises, hybrid, or any public cloud. It integrates with your DevOps process, and has connection points to a variety of development tools.

How does Application Insights work?

You install a small instrumentation package (SDK) in your application or enable Application Insights using the Application Insights Agent when supported. The instrumentation monitors your app and directs the telemetry data to an Azure Application Insights Resource using a connection string.

You can instrument not only the web service application, but also any background components, and the JavaScript in the web pages themselves. The application and its components can run anywhere. It doesn't have to be hosted in Azure.

Application Insights instrumentation in your app sends telemetry to your Application Insights resource.

Diagram of the Application Insights instrumentation.

In addition, you can pull in telemetry from the host environments such as performance counters, Azure diagnostics, or Docker logs. You can also set up web tests that periodically send synthetic requests to your web service.

All these telemetry streams are integrated into Azure Monitor. In the Azure portal, you can apply powerful analytic and search tools to the raw data.

In Application Insights, telemetry from Business Central is logged in the traces and pageViews tables. Currently, Business Central offers telemetry on many operations, including:

  • Authorization - Provides information about user sign-in attempts. Information includes success or failure indication, reason for failure, user type, and more.

  • Company lifecycle - Provides information about creating, copying, and deleting of companies.

  • Long running operation (SQL query) - Provides information about SQL queries that take longer than expected to execute.

  • Report generation - Provides information about the execution of reports.

  • Web service requests - Provides information about the execution time of web service requests.

  • Extension lifecycle - Provides information about installing, updating, and uninstalling extensions.

  • Page views - Provides information about pages opened in the client.

  • Configuration package lifecycle - Provides information about importing and exporting configuration packages.

  • Email - Provides information about email activities.

  • Job queue - Provides information about job queue entry execution.

  • Permissions - Provides information about adding and removing permissions and permission sets.

  • Retention policy - Provides information about retention policy operations.

  • Database deadlocks - Provides information about deadlocks that occur in the database.

  • Database lock timeouts - Provides information about database locks that timed out.

  • Database wait statistics - Provides information about the wait categories and the wait times that a query runs into.

  • Long running AL method - Provides information about AL methods that take longer than expected to run.

  • Performance Toolkit (BCPT) - Provides information about test results from running the Business Central Performance Toolkit.

For the complete list of available telemetry signals, see Available telemetry.

Sending telemetry data to Application Insights requires you have an Application Insights resource in Azure. Once you have the Application Insights resource, you can start to configure your tenants to send telemetry data to your Application Insights resource. The configuration is different for Online and On-premises.

Telemetry from Business Central is stored in Azure Monitor Logs in the traces and pageViews tables. You can view collected data by writing log queries. Log queries are written in the Kusto query language (KQL).

As a simple example, you can try the following steps:

  1. In the Azure portal, open your Application Insights resource.

  2. In the Monitoring menu, select Logs.

  3. On the New Query tab, type the following to get the last 100 traces:

    traces | take 100 | sort by timestamp desc

On the Business Central BCTech repository on GitHub, samples of KQL code are available to make it easy to get started using Application Insights.

For more information, see the Business Central BCTech repository on GitHub.

Telemetry

For monitoring and analyzing performance issues in the Business Central service, we recommend connecting Azure AppInsights to the environments that you want to get signals from.

You can see some ways where telemetry can help troubleshoot performance issues by referencing the Analyzing performance issues using telemetry section of the How to work with a performance problem page.

Sending telemetry to Microsoft Azure Application Insights

If you want to send telemetry to Application Insights, you should follow these steps.

  1. If you don't already have one, get a subscription to Microsoft Azure. (You can go to https://azure.microsoft.com/ to get a subscription.)

  2. Create an Application Insights resource in Azure.

    • The Application Insights resource will be assigned a connection string. Copy this connection string because you'll need it to enable Application Insights in the Business Central administration center.

    • The Application Insights resource can be in any Azure tenant that is accessible to your organization. For example, a delegated administrator from the reselling partner is the person analyzing the telemetry. But this person might not have access rights the customer's Azure instance. This scenario enables the partner to send the telemetry to their own Application Insights instance.

    • For more information, visit the Create an Application Insights resource page.

  3. In the Business Central administration center, select Environments, and then select the environment that you want to change.

  4. On the Environment page, select Application Insights Connection String.

  5. On the Application Insights page, enter the connection string in the Connection String field, and select Save.

This process requires a restart to the environment, which is triggered automatically after you select to save the connection string. Plan to complete this during non-working hours to avoid any disruptions.

Cleaning Up

If the Application Insights resource is tied to your partner account, and you end the relationship with a customer where you have set up telemetry based on your account's connection string, you need to remove the connection string while you still have access to that customer's Business Central administration center.

Control telemetry cost

Azure Application Insights is billed based on the volume of telemetry data that is sent (data ingestion) and how long time you want data to be available (data retention).

Check the Azure Application Insights documentation for up-to-date information on pricing at Azure Monitor Pricing.

To control the cost of data ingestion, you can:

  • Set a daily cap on how much data can be ingested, and set an alert for when the cap is reached.

  • Use sampling to only ingest a percentage of the inbound data.

  • Use data collection rules (DCR) to filter away the telemetry that you don't need. Data collection rules require a workspace-based Application Insights resource and are defined on the workspace, under Tables, for the AppTraces and AppPageViews tables.

To reduce data retention cost, use the default retention period for the Application Insights resource, or purge data by using user-defined filters.

For more information, see Control Telemetry Cost.

Viewing telemetry data with Power BI

To make it easier to analyze Business Central telemetry, we've developed two Power BI apps available from the Microsoft commercial marketplace. One app is for telemetry on environments. The other one is for telemetry on apps/extensions (the telemetry defined in the app.json). Both apps are free and open source but requires Power BI pro licenses to install.

For more information, go to Analyze and Monitor Telemetry with Power BI.

Setting up alerts 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 easier to define such alerts. You can set up alerts on telemetry events with various tools depending on your role.

If you're a project manager, product owner, or functional consultant, consider using the no-code tool Power BI Metrics for your alerting needs.

If you prefer more control, consider using one of these low-code tools for your alerting needs.

  • Azure Application Insights Alerts

  • Azure Logic Apps

  • Power Automate

For more information, see Alert on Telemetry.

Business Central telemetry FAQ

We have compiled a list of frequently asked questions (FAQ) on telemetry. See Telemetry FAQ.