Skip to content

Latest commit

 

History

History
157 lines (115 loc) · 6.35 KB

app_insights_for_bots.md

File metadata and controls

157 lines (115 loc) · 6.35 KB

Application Insights Telemetry for Bots

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).

Table of Contents

Provision Application Insights

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.

Deployment using the MsBot command line tool

Deployment using the Azure Portal

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.

Configuring Sentiment

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. Enabling Sentiment Click on "Use sentiment analysis to determine if a user's utterance is positive, negative, or neutral." checkbox.

Application Insights Queries

The following provide some examples of retrieving data about your bot, to better understand how your bot (and related services) are performing.

LUIS Intents Piechart

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.

Example Report

customEvents
| where timestamp >= ago(24h)
| where name startswith "LuisIntent"
| summarize count() by name
| order by count_ desc
| render piechart

P50, P95, P99 for Services

The following query demonstrates querying data from the Application Insights dependencies table which models calls to external components.

Example Report

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

Power BI

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

Installation

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.

Overall Usage

Example Report

Conversation Flow

Example Report

Demographics

Example Report

Sentiment

Example Report

Users and Conversations

Example Report

Common Words

Example Report

Word Cloud

Example Report

Using Application Insights in Visual Studio

Within Visual Studio, Application Insights events can be queried in the "Application Insights Search" window. For more details, see the Application Insights documentation. Example Visual Studio Session 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: Example Track Operation With this view, you can quickly understand where time is being spent within your bot.

Disabling Application Insights

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;

Troubleshooting

I am not seeing all event types.

In C# ASP.Net Core, ensure the appsettings.json file contains an InstrumentationKey:

 {
  "botFilePath": "Mybot.bot",
  "botFileSecret": "MySecret",
  "ApplicationInsights": {
    "InstrumentationKey": "<MyAppInsights_key>"
  }
}