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:
- Access to Azure Application Insights
- Basic understanding of KQL syntax
- 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
2. Find out the Sitecore log categories
traces
| extend category = tostring(customDimensions.Category)
| distinct category
3. Analysis of publishing logs
traces
| extend category = tostring(customDimensions.Category)
| where category has 'publishing'
4. Analysis of crawling logs
traces
| extend category = tostring(customDimensions.Category)
| where category has crawling
5. Analysis of application logs
traces
| extend category = tostring(customDimensions.Category)
| where category has 'log'
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'
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'
How to Use These Queries
-
Open the Azure Portal.
-
Navigate to your Application Insights resource.
-
Click on “Logs (Analytics)”.
-
Copy and paste one of the above KQL queries.
-
Modify the time range using the dropdown menu.
-
Run the query and analyze the results.
-
Note that you can save these 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!