Application Insights is a Azure service which enables analytics about your applications, infrastructure and network.
The Bot Framework can use the Application Insights telemetry to provide information about how your bot is performing, and track key metrics.
The Bot Framework SDK ships with several samples that demonstrate how to add telemetry to your bot and produce reports (included).
- Provision Application Insights
- Configuring LUIS Sentiment
- Application Insights Queries
- Power BI Report
- Using Application Insights in Visual Studio
- Disabling Application Insights
- Troubleshooting
The Application Insights service must be created before the bot is deployed, since configuration strings must be provided to the Bot Configuration file. Application Insights can be provisioned through the Azure Portal or through the MsBot tool.
The Azure portal can be used to deploy your Application Insights using the Azure Portal. You may choose this option if you already have an existing Application Insights deployment or you want to place Application Insights into a separate Azure Resource Group.
LUIS enables sentiment to be logged. This can be enabled through the LUIS portal. Sentiment is enabled for each application. To enable sentiment, log in to the portal, select "My Apps" , click on the specific application you want to enable sentiment. Select "Manage" on the upper menu, and "Publish Settings" on the side menu. It should resemble below. Click on "Use sentiment analysis to determine if a user's utterance is positive, negative, or neutral." checkbox.
The following provide some examples of retrieving data about your bot, to better understand how your bot (and related services) are performing.
The following query demonstrates querying data that was generated by the LUIS telemetry in the sample. The telemetry logs the top intent from the recognizer (in addition to some other properties), and logs an Application Insights Custom Event.
customEvents
| where timestamp >= ago(24h)
| where name startswith "LuisIntent"
| summarize count() by name
| order by count_ desc
| render piechart
The following query demonstrates querying data from the Application Insights dependencies
table which models calls to external components.
CosmosDB
dependencies
| where timestamp >= now(-1d)
| where type == "Azure DocumentDB"
| summarize percentiles(duration,50,95,99) by bin (timestamp, 1m)
| render timechart
Azure Blob Storage
dependencies
| where timestamp >= now(-1d)
| where type == "Azure blob"
| summarize percentiles(duration,50,95,99) by bin (timestamp, 1m)
| render timechart
LUIS
dependencies
| where timestamp >= now(-1d)
| where type == "HTTP" and name contains "/luis"
| summarize percentiles(duration,50,95,99) by bin (timestamp, 1m)
| render timechart
The samples provide a PowerBI template that can be used to understand how the bot is performing. The Power BI template is located under the following folder:
Middleware\Telemetry\ExamplePowerBIDashboard.pbit
The PowerBI Desktop client is available for Windows clients. Alternatively, you can use the PowerBI service. If you don't have a PowerBI service account, sign up for a free 60 day trial account and upload the PowerBI template to view the reports.
Below are some sample pages of the report.
Within Visual Studio, Application Insights events can be queried in the "Application Insights Search" window. For more details, see the Application Insights documentation. Clicking on "Track Operation" on the details of any event can give you a visualization of where time is being spent, using the events in the telemetry that are automatically correlated: With this view, you can quickly understand where time is being spent within your bot.
To turn off Application Insights logging for C#, open up the Startup.cs
file and uncomment the following lines:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Uncomment to disable Application Insights.
// var configuration = app.ApplicationServices.GetService<Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration>();
// configuration.DisableTelemetry = true;
In C# ASP.Net Core, ensure the appsettings.json
file contains an InstrumentationKey
:
{
"botFilePath": "Mybot.bot",
"botFileSecret": "MySecret",
"ApplicationInsights": {
"InstrumentationKey": "<MyAppInsights_key>"
}
}