Walkthrough: Enabling Application Map for Application Insights for xConnect

Version:

You use the Application Map (part of Azure Application Insights) to get a visual representation of the dependency relationship of components of your application. Each node in the map represents an application component (application node) or its dependency (dependency node). Components are independently deployable parts of a distributed application. The Microsoft documentation for Azure has more information. This visual representation helps you spot performance bottlenecks or failure hotspots across all components of your distributed application.

The Application Map of the Application Insights service is not enabled by default when you deploy Sitecore XP to the Microsoft Azure App Service.

When you deploy Sitecore to the Microsoft Azure App Service, Sitecore is integrated with the Application Insights service by default. To optimize resource consumption, Sitecore does not collect dependency telemetry events that record information about outgoing HTTP and SQL connections from a Sitecore XP instance by default. The Application Map feature uses these telemetry events to visualize connections between the services and display diagnostic information.

Important

In Sitecore XP 10.5, do not configure Application Insights by using a standalone instrumentation key setting such as AppInsightsKey. Use the full Application Insights connection string with the AppInsightsConnectionString setting instead.

This topic shows you how to enable the dependency collector and thereby enable the Application Map.

This walkthrough describes how to:

  • Configure the Application Insights connection string
  • Enable the dependency collector for Sitecore roles
  • Enable the dependency collector for xConnect roles
  • Enable the dependency collector for xConnect services
  • Specify component role names for xConnect roles

Configure the Application Insights connection string

Before enabling Application Map for xConnect roles and services, configure the Application Insights connection string.

The connection string usually has the following format:

InstrumentationKey={guid};IngestionEndpoint={url};LiveEndpoint={url};ApplicationId={guid}

Although the connection string contains an InstrumentationKey value, Sitecore XP 10.5 uses the full connection string through the AppInsightsConnectionString setting.

In each applicable AppSettings.config file, replace the previous standalone instrumentation key setting:

<add key="AppInsightsKey" value="..." />

with the following connection string setting:

<add key="AppInsightsConnectionString" value="InstrumentationKey={guid};IngestionEndpoint={url};LiveEndpoint={url};ApplicationId={guid}" />

Replace the placeholder values with the connection string from your Application Insights resource.

Enable the dependency collector for Sitecore roles

To enable the collection of dependency telemetry events for Sitecore roles:

  • In the wwwroot folder, uncomment the following line in the ApplicationInsights.config file:

    <!-- <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/> -->

    After uncommenting, the line should look like this:

    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/>

Perform this step on each Sitecore role that you want to track in Application Map.

Enable the dependency collector for xConnect roles

To enable the collection of dependency telemetry events for xConnect roles:

  1. In the wwwroot folder, uncomment the following line in the ApplicationInsights.config file:

    <!-- <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/> -->

    After uncommenting, the line should look like this:

    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/>
  2. In the role's AppSettings.config file, replace the previous instrumentation key setting:

    <add key="AppInsightsKey" value="..." />

    with the connection string setting:

    <add key="AppInsightsConnectionString" value="InstrumentationKey={guid};IngestionEndpoint={url};LiveEndpoint={url};ApplicationId={guid}" />
  3. Keep or update the role name setting as needed:

    <add key="AppInsightsRoleName" value="XConnect Collection" />
Note

In Sitecore XP 10.5, you do not need to manually enable or update sc.AppInsights.Initializer.xml for this change. The required initializer configuration is included by default.

You have to perform these steps on each xConnect role you want to track.

Enable the dependency collector for xConnect services

You can enable dependency collection for the supported xConnect services.

The supported services include:

  • XConnect Search Indexer

    The XConnect Search Indexer web job is hosted in the xConnect Collection Search role:

    xp-xc-search/App_Data/jobs/continuous/IndexWorker
  • Marketing Automation Engine

    The Marketing Automation Engine web job is hosted in the Marketing Automation Operations role:

    xp-ma-ops/App_Data/jobs/continuous/AutomationEngine
  • Sitecore Cortex Processing Engine

    The Sitecore Cortex Processing Engine web job is hosted in the Sitecore Cortex Processing role:

    xp-cortex-processing/App_Data/jobs/continuous/ProcessingEngine

To enable the collection of dependency telemetry events for an xConnect service:

  1. In the root folder of the web job, uncomment the following line in the ApplicationInsights.config file:

    <!-- <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/> -->

    After uncommenting, the line should look like this:

    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/>

    For example, for the XConnect Search Indexer, the file is located at:

    App_Data/jobs/continuous/IndexWorker/ApplicationInsights.config
  2. In the web job's AppSettings.config file, replace the previous instrumentation key setting:

    <add key="AppInsightsKey" value="..." />

    with the connection string setting:

    <add key="AppInsightsConnectionString" value="InstrumentationKey={guid};IngestionEndpoint={url};LiveEndpoint={url};ApplicationId={guid}" />
  3. Keep or update the role name setting as needed:

    <add key="AppInsightsRoleName" value="XConnect Search Indexer" />
Note

In Sitecore XP 10.5, you do not need to manually enable or update sc.AppInsights.Initializer.xml for this change. The required initializer configuration is included by default.

You have to perform these steps on each xConnect service you want to track.

Specify component role names for xConnect roles

By default, each xConnect role and service are represented as a separate application node with its own role name.

The role name for the application node is specified in the AppSettings.config file by using the AppInsightsRoleName application setting key. The Application Insights connection string is specified in the same file by using the AppInsightsConnectionString application setting key.

Example:

<?xml version="1.0" encoding="utf-8"?>
<appSettings configBuilders="SitecoreAppSettingsBuilder">
  <add key="configurationDirectorRoot" value="~/App_Data" />
  <add key="configurationEnvironment" value="Production" />
  <add key="AllowInvalidClientCertificates" value="True" />
  <add key="validateCertificateThumbprint" value="CBC23042652046E7C7DEF49AAC292A41D98D048" />
  <add key="AppInsightsConnectionString" value="InstrumentationKey={guid};IngestionEndpoint={url};LiveEndpoint={url};ApplicationId={guid}" />
  <add key="AppInsightsRoleName" value="XConnect Standalone" />
</appSettings>

Do not use the previous standalone instrumentation key setting:

<add key="AppInsightsKey" value="..." />

Use the full connection string setting instead:

<add key="AppInsightsConnectionString" value="InstrumentationKey={guid};IngestionEndpoint={url};LiveEndpoint={url};ApplicationId={guid}" />
If you have suggestions for improving this article, let us know!