Troubleshooting Application Insights
Most problems you might encounter with Application Insights are about setting up and getting things working. Here are some tips to help you solve the most common issues.
Application Insights has a newer version that is part of Microsoft Azure, and an older version that is part of Visual Studio Online (VSO). The topics in this part of the MSDN Library are about the VSO version.
For new projects, the better experience will be with the Azure version. You get that automatically if you install Visual Studio 2013 Upgrade 3 or later.
For existing projects that already have Application Insights, it’s easier to stay with the VSO version. You can still use the latest upgrade of Visual Studio to work with it.
There are two ways in:
Start from Visual Studio 2013. Install Application Insights Tools for Visual Studio, and then add Application Insights to your web app, Windows Phone, or Windows Store project. Pick the instructions for your type of application under Start monitoring an ASP.NET application or web site.
Adding Application Insights to your project lets you see data about what your users are doing with your app. If it’s a web application, or if part of it is a web service, your next steps can be to add performance monitoring and Monitor your web app's availability and responsiveness.
Start from the Application Insights portal. If your team has a Visual Studio Online account, just go to http://< your team account>.visualstudio.com and choose the Application Insights tile. The first time you do this, you’ll see instructions for monitoring an application. This is an easier way in if you have Visual Studio 2012.
To install the Tools, you have to have Visual Studio 2013.
If you’re using Visual Studio 2012, you can use Application Insights, but there are a few extra steps to get started.
In Visual Studio 2013, in the Tools menu, choose Extensions and Updates. Select Online, and then enter the search string “Application Insights” (with the quotation marks).
By installing the Application Insights SDK in your app project, you get data on the USAGE pages that show you what people are doing with your app.
It takes 5-15 minutes for data to appear in the USAGE pages. Instead, watch for data Raw event stream tile on the dashboard. Data appears there within a few seconds.
Or you can see more detail on the Diagnostics, Streaming Data page.
Once you see data in the raw event stream, the Usage pages show aggregated data about 15 minutes later.
Check that you’re configured for streaming.
You have to install Application Insights Tools for Visual Studio 2013 in order to see streaming data. If you are using Visual Studio 2012, wait 5-15 minutes to see data in the Usage pages.
In Visual Studio, on the Build menu, open Configuration Manager. Check that the Active Build Configuration is Debug.
Open ApplicationInsights.config in the root folder of your app project and check the following elements:
This element determines which profile that is active when you build in Debug mode:
Inside <Profile name="Development">, check that you see these elements:
<ServerAnalytics enabled="true"> <!-- or ClientAnalytics for Windows Store and Phone apps --> <SendToRawStream>true</SendToRawStream> <CollectUserName>true</CollectUserName> <CollectMachineName>true</CollectMachineName> <DataUploadIntervalInSeconds>0.1</DataUploadIntervalInSeconds> </ServerAnalytics>
(I don’t see data in the Streaming page; or I know that I’m not configured for raw event streaming, but I don’t see data in USAGE even after 15 minutes.)
[Windows Store apps] On the device, make sure that Advertising is enabled.
Open the Settings charm, choose Change PC Settings, Privacy, and then enable Let apps use my Advertising Id.
Watch the debug output. The SDK logs messages to the Debug Output window in Visual Studio. You should see initialization messages, followed by messages when events are logged and sent.
[Windows Phone and Store apps] To see the SDK log messages:
Open the properties of your Windows Phone or Store app project.
In the Debug page, [Phone] change UI Task to Native Only, or [Store] change Debugger Type to Native or Mixed (Managed and Native).
Run your app in debug mode. To filter out all but the Application Insights messages, open the context menu of the Output window, and disable all types of messages except Program Output.
[Windows Store and Phone apps] Make sure you don’t send call logging methods before InitializeComponent() in the App constructor.
It stopped updating? Refresh the page. If your app sends no data for 90 seconds, the polling interval of the raw event view gradually increases to 30 minutes. It will speed up again after a poll that sees new data, or if you refresh the page.
Old data vanished? The raw event stream keeps the events only for two hours, and has a limited size, so you won’t be able to scroll back to old individual events. But you will be able to see the aggregated events in the USAGE pages.
Add following to configurations section of web.config or to the app.config. Make sure that sufficient permissions for tracing are provided on the folder specified below. Other listeners can be also added. See DiagnosticMonitorTraceListener and System.Diagnostics.TraceListener.
<system.diagnostics> <trace autoflush="true"></trace> <sources> <source name="Microsoft.ApplicationInsights.Telemetry.Services" switchValue="All"> <listeners> <add name="DiagnosticMessageTraceListener" type="System.Diagnostics.TextWriterTraceListener" traceOutputOptions="ProcessId, ThreadId, DateTime" initializeData="location of the log file" /> </listeners> </source> </sources> </system.diagnostics>
Run your app and then terminate it.
You can find log files under %localappdata%\Packages\*\LocalState\MS.CA
However, be aware that the log files are deleted as soon as they are sent. Logs are sent on startup or resume, and so it can be particularly difficult to see events that are generated on launch. If you want to see launch events, you might want to disable the device’s network.
Run your app and then terminate it by using the back button.
Use the tool to inspect the phone’s isolated storage.
You should see log files under the Microsoft.ClientAnalytics folder.
However, be aware that the log files are deleted as soon as they are sent. Logs are sent on startup or resume, and so it can be particularly difficult to see events that are generated on launch. You might want to disable the phone’s network to be able to see those events.
Under the PERFORMANCE pages in Application Insights, you can get reports that tell you if your web service throws exceptions or has performance issues. Assuming you followed the instructions to set up performance monitoring, here are some tips for fixing the most common issues.
Try the drop-down menu of application components. If there are other names in the menu, look to see if the data is appearing there.
Wait 5 minutes and then refresh the page.
Do you have two applications on the server with the same component name? Open ApplicationInsights.config in the root folder of each web app and make sure <ComponentName> is different in each one.
Do you have two applications on the server that are configured to send data to different Application Insights accounts? Open ApplicationInsights.config in the root folder of all the web apps and make sure that <AccountID>, <LicenceKey> are the same in every one.
Microsoft Monitoring Agent can only send data to application components in one Application Insights account. If you decide to use the first account, change the AccountId and LicenceKey in ApplicationInsights.config. To see the data, you’ll have to log into that Visual Studio Online account. If you decide you want to change to the new account, open the Microsoft Monitoring Agent control panel to reset the default account credentials, and then either remove the old ApplicationInsights.config, or change its credentials.
ApplicationInsights.config in the root folder of your web app. Change <ComponentName> to be the name under which the USAGE data appears. Upload the edited file to your web server.
When the data appears in the right place, you can delete the old application component under Overview, Applications.
Data is only sent if your web service throws exceptions or crosses performance thresholds. You must be using your web service for this to happen.
If you reduce the threshold, you’ll see more data. In ApplicationInsights.config in the root folder of your web app, reduce <PerformanceThreshold>. Upload the edited file to your web server.