Shiham Sham

Essential KQL Queries for Troubleshooting Sitecore XP on Azure



When troubleshooting Sitecore XP instances hosted on Azure, having access to detailed logs and metrics through KQL (Kusto Query Language) is crucial. This guide provides a collection of essential KQL queries that can be used in Application Insights log query window to analyze and troubleshoot both CM and CD instances.

Prerequisites

Before using these queries, ensure you have:

  1. Access to Azure Application Insights
  2. Basic understanding of KQL syntax
  3. Access to Sitecore XP logs in Application Insights

You may refer to Mastering Sitecore MCS PaaS Logging with Azure Application Insights to learn the basics on Azure Application Insights usage on a Sitecore MCS PaaS environment.

Essential KQL Queries for Sitecore XP Troubleshooting

1. Find out the Sitecore roles that aggregate logs to Application Insights

traces 
| extend roles = tostring(Properties.Role) 
| distinct roles 

Find out the Sitecore roles that aggregate logs to Application Insights

2. Find out the Sitecore log categories

traces
| extend category = tostring(customDimensions.Category) 
| distinct category 

Find out the Sitecore log categories

3. Analysis of publishing logs

traces 
| extend category = tostring(customDimensions.Category) 
| where category has 'publishing' 

Analysis of publishing logs

4. Analysis of crawling logs

traces 
| extend category = tostring(customDimensions.Category) 
| where category has crawling 

Analysis of publishing logs

5. Analysis of application logs

traces 
| extend category = tostring(customDimensions.Category) 
| where category has 'log' 

Analysis of application logs

5. Analysis of audit logs on CM

traces 
| extend category = tostring(customDimensions.Category) 
| extend role = tostring(customDimensions.Role) 
| where message has 'audit' and role has 'CM' 

Analysis of audit logs on CM

6. Analysis of search logs on CD

traces 
| extend category = tostring(customDimensions.Category) 
| extend role = tostring(customDimensions.Role) 
| where category has 'search' and role has 'CD' 

Analysis of search logs on CD

How to Use These Queries

  1. Open the Azure Portal.

  2. Navigate to your Application Insights resource.

  3. Click on “Logs (Analytics)”.

  4. Copy and paste one of the above KQL queries.

  5. Modify the time range using the dropdown menu.

  6. Run the query and analyze the results.

  7. Note that you can save these queries in the Azure portal and reuse them when needed.

Save KQL queries in the Azure portal and reuse them when needed

Common Use Cases

  • Tracking audit and publishing operations and their impact
  • Monitoring instance health
  • Identifying slow-performing pages or features

These queries serve as a foundation for troubleshooting Sitecore XP instances on Azure. Customise them based on your specific requirements and environment. Remember to validate the queries against your Application Insights data to ensure they work correctly with your particular implementation.

Happy troubleshooting!



Similar Posts

Comments