Using KQL for Monitoring and Optimizing Microsoft Copilot Studio

Kusto Query Language (KQL) enables developers to monitor, analyze, and troubleshoot their Copilot implementations through Azure Application Insights. Below are some essential KQL queries designed to optimize Copilot Studio’s performance and enhance user experience.


1. Analyze Overall Bot Usage

requests
| where url endswith "/messages"
| summarize MessagesCount = count() by timestamp, user_Id
| order by timestamp desc
  • Usage: Tracks the number of messages processed by Copilot Studio over time per user.
  • Benefit: Provides a snapshot of bot activity, identifying usage patterns and peak interaction times.

2. Monitor Latency in Bot Responses

requests
| where url endswith "/messages"
| summarize AvgDuration = avg(duration) by timestamp, user_Id
| order by AvgDuration desc
  • Usage: Calculates the average response time for each bot message.
  • Benefit: Helps detect latency issues in bot responses, allowing timely adjustments for performance improvements.

3. Identify High-Frequency Errors

exceptions
| summarize ErrorCount = count() by problemId, type, outerMessage
| where ErrorCount > 5
| order by ErrorCount desc
  • Usage: Lists errors occurring more than five times by type and message.
  • Benefit: Flags recurring issues, enabling developers to prioritize and address the most critical errors affecting user experience.

4. Track User Engagement Duration

pageViews
| where client_Type == "Browser"
| summarize AvgSessionDuration = avg(duration) by user_Id
| order by AvgSessionDuration desc
  • Usage: Shows the average session duration for each user interaction.
  • Benefit: Measures user engagement, helping to assess the bot’s relevance and the level of user interest in the conversation.

5. Detect Performance Bottlenecks in API Calls

dependencies
| where success == false
| summarize FailureCount = count() by target, name
| order by FailureCount desc
  • Usage: Finds external API calls with high failure rates.
  • Benefit: Identifies dependency issues, enabling quick resolution to maintain smooth bot operation.

6. Evaluate User Retention Across Sessions

customEvents
| where name == "UserLogin"
| summarize SessionsCount = dcount(session_Id) by user_Id
| order by SessionsCount desc
  • Usage: Counts the number of unique sessions for each user.
  • Benefit: Helps understand user retention by tracking repeat interactions, indicating overall satisfaction and engagement.

7. Examine User Exit Points

Views
| summarize ExitPages = count() by name
| where timestamp == max(timestamp)
| order by ExitPages desc
  • Usage: Lists the last page each user visited before ending the session.
  • Benefit: Highlights possible exit points where users might be facing challenges, leading to opportunities for UX improvements.

Leave a comment