📜 ⬆️ ⬇️

Application Insights for Visual Studio Online - a powerful diagnostic tool in the developer's kit

Hello! Today we have an interesting topic - application diagnostics and monitoring. You always want to have a tool that will be (preferably free of charge, but if not, then with reasonable prices):

There were a lot of great tools, but I wouldn’t have found all the functions that would integrate, and preferably integrate all the above experience into an ecosystem that already exists - my Visual Studio. If you are interested in such a new tool - Application Insights - with which you can not only watch, but also download, for example, files for IntelliTrace - well, under the cat. I’m clarifying - this is not a mega-guide about “how to do”, this is a review, so there will be a lot of bright pictures.

So, we understand that “yes, we have a virtual machine, we can do everything with it,” and “yes, this is PaaS, and we need it so that we don’t have to do everything with the virtual machine, and once and laid out the application. " But what happens when we, using any of the approaches, still post our application? Then begins testing and catching bugs. There is no perfect software - even if we seem to have foreseen everything, we can forget about some trifles in the environment of the application - and get an interesting bug. Or a bug due to the behavior of the neighboring component (or, again, the ecosystem), which was observed for exactly ten seconds. How to catch all this? Of course, there are many tools - Intellitrace, performance counters, tests, and much more. But if we will have a tool that combines all of the above?

The tool is called Application Insights. This is a component of Visual Studio Online, and it is free for Visual Studio Online accounts ( learn more about VSO), with up to 5 team members. You can deploy it directly into the application (for example, Cloud Service Windows Azure), install its agent on the server (Windows Server) and tell it to start monitoring all sites and applications that are on this server, or link it to the System Center Operation Manager (what is the most difficult scenario, since it is, to put it mildly, a level higher than “just a tool”).
')
In order to use AI, we need:


What will we do first? Configure the infrastructure. Next - see what AI can do.

Infrastructure setup


Let's set up the basic element of our experience in using AI –VM Visual Studio 2013 ALM. This VM is optional and, if you have Visual Studio Ultimate 2013, you can skip this item. If not, then the process of obtaining this VM is described here .
The VM will need an external Internet, so if you are using Hyper-V, you will need to create a virtual switch.
Log in to the VM under the account Brian Keller (VSALM \ Brian). Password: P 2 ssw 0 rd . We will launch Visual Studio Ultimate 2013, and enter credentials for access to Visual Studio Online, which should have been registered before the “What shall we do?” Item.



Let's create the virtual machine in Azure. If you already have a web server with running applications - you can work there, the actions are no different.









Connect to the VM by clicking the Connect button.



Now let's activate AI in Visual Studio Online. To do this, go to https://account.visualstudio.com ([account] - the name of your account) and click on Try Application Application Insights. If you ask for the code for an invite, use VSAppInsights 6225162023 .



After moving to the AI ​​page, we will see the instructions. First of all, we need to download the Microsoft Monitoring Agent (MMA) and install it on the server. This agent will enable monitoring of applications on the server. It can be downloaded either on the instructions page or via the link . During installation, the only non-standard issues are agent connection mode and key. It can be installed and connected to VSO, to SCOM, or installed without connection. We will be enough to connect to the VSO.



Copy the Account ID and Instrumentation Key values ​​from the AI ​​portal, paste them into the appropriate fields on the VSO connection settings page, and click Validate Connection (this is required). Install the option to immediately start monitoring all applications running on the server after the agent is installed. After the agent is installed, a command window will start, which will report on the start of monitoring applications.



For interest, you can explore the Monitoring Agent PowerShell Prompt, which is installed along with the agent — a set of cmdlets that you can use to, for example, get a list of monitored applications and their status (“Get-WebApplicationMonitoringStatus” cmdlet). We will not consider them yet.



We return to the AI ​​portal, on which the main AI functionality will appear as a set of tabs: Overview, Availability, Performance, Usage, Diagnostics. If they are not there, you need to wait - the data has not yet been loaded.



We set up the infrastructure. This is sufficient (especially if you decide to go to Production) for the receipt and analysis of data. If not, you can use any load testing mechanism to simulate the load. Much depends on the size of the load - for example, if a backend is being tested, it is not necessary that a problem may arise when processing 1000 lines from a document. Have you planned that the document will be a billion lines? It is important. AI will show if too many resources are consumed, and this will be a valuable factor for further planning and it’s good if we see it in the early stages of development.

Monitoring and Profiling with Application Insights - Overview


Let's go back a bit and remember what AI is. AI is a sub-functionality of Visual Studio Online, with which any team member can monitor availability, performance, and various aspects of using applications / services in real mode. Below are a few notes on the AI ​​functions:





Availability


Go to the Availability tab.



Availability can be viewed from different angles, and each analyst can have his own ideas about it. Immediately after creating a project and connecting it to the AI, the Availability tab will offer to create a Synthetic Monitor, or how the user wants to monitor the availability of the project. Let's create the easiest one - the URL Ping Test, it is proposed to create it right away.



After creating the monitor, click on the green button that appears to go to the report.
By default, a report is available for the last 24 hours. Immediately after creation, we will not find anything interesting - in order to see a representative sample, you need to wait and load the project. Further, the screenshots will use several projects that are in production.
The lower graph displays 24 hours continuously - so that at any time you can see the data for the desired period by selecting it. After the period is selected, the graphs above will respond with a minimum delay.



Pointing on the peaks, you can see the results of the monitor. We had a simple monitor with ping, so the result will be either a digit or a cross symbol - it means that it did not reach.





Monitors are created by clicking on the appropriate button-plus. Two options are available - New Single URL Test and New Multistep Web Test . Single URL Test is needed to track a single page; you can download an already configured Web Test from Visual Studio to Multistep Web Test. With Multistep Web Test, let's look at one of the following articles, Single URL Test fits into one conversation.



To view detailed information on a specific monitor, click on its name. Here - information about a specific monitor, the performance of its work, geographical locations and so on. This information is an excellent source that may suggest the need to, for example, add servers serving a specific region, or rework logic.



But what are these mistakes? Colleagues from Japan waited twenty seconds, then something happened. Click on this cross to see what.



A window will appear with information about this request.



Now I understand - a timeout error. We can move on and download the Web Test Result file in Visual Studio. Complex tests - Multiple - provide an opportunity to perform unit tests of specific pages and, for example, add test entities. If an error occurs in such a process, it will again be reflected in the chart and you can see where the exception has flown.
With Availability, everything (the big topic about Multiple Web Test will be discussed later). Go to the Performance tab.

Performance


After switching to the Performance tab, we will have a large amount of information to think about for a certain period - the period selected on one of the tabs will be maintained during the session.



The first block is “Response Time and Load vs. Dependencies ”- shows the speed of requests, the average speed of the request and various dependencies. As on the Availability tab, this block has two schedules - for the selected period and for 24 hours.
The next block - “Response Time Distribution” - shows a graph with the distribution of time spent on responses. Everything is fine with us - most requests took less than <50 ms.



The slowest requests were awarded in the AI ​​of a separate block - “Top 10 Slowest Requests by Issue Count”. This block does not have a special wealth of information, but allows you to see which page / presentation has been loading the longest. Pay attention to MVC View rendering - the element rendering itself was not that long, the main time was spent on loading.



Another block - “Average Instance Count” - shows the average number of servers. If you have a farm, it will show the distribution by quantity. In our case, this is one server, and it will not work to benefit from this fact.
The “Exceptions Rate” block is one of the most interesting. It shows the distribution of the number of exceptions per second.



As you can see, something very active was happening - exceptions occurred. The Exceptions Rate link leads to more detailed information - by clicking we will go to the Diagnostics tab customized for this information. There is also the Exception Events button, which will bring us all the exceptions that occurred during the execution of the application. All this data can be sorted, for example, by exception class.
Clicking on an exception will bring up another window with information about this exception, and, attention, a link to the IntelliTrace file - the history of each exception is saved.



The remaining blocks are information about server resources — CPU, network, memory — allocated for the application. The reason for the strange behavior of the application or even the server is not always possible to detect immediately (the thought of checking the logs or the Task Manager may come too late), so the load distribution may show useful anomalies.



Each block has a name, when clicked, a transition to the configured Diagnostics tab takes place. For example, if you paid attention to the memory anomaly on the server, then it is worth it to check this tab - perhaps you had a Memory Event. Each such Memory Event will have a memory dump file, which can be used to determine what caused this behavior.
Go to the next tab - Feature Usage.

Features


This tab depends on whether you set up your telemetry code using Telemetry SDK. This will also be considered in the following articles, now we will review how it works.
Telemetry is divided into a certain number of features. The first feature, Top Pages, shows how users use the application, where they go and how often.



The second block, Relative% of Sessions, shows the distribution of the number of requests to different sections of the site during the session (the period the user is on the site).



The second feature - Page Views - shows the hierarchy of requests for various pages, including the URL structure and hourly breakdown.



Here you can see additional information on different pages: the average number of unique users, the number of sessions, and so on.



Inside Page Views there is a section DETAILS - an hourly breakdown of information on visits.



The Events feature contains developer-defined events that need to be logged and displayed in AI. The Event Insights feature is directly related to Events and shows extended information on events.
The Slowest Requests feature shows the average load time for various pages.



This is with regard to features. I recall that the Usage tab is already based on the actions of the developer, and the developer has the right to interact with AI in this aspect as he needs it. Moving on to the next section USAGE - Users.



This section is about customer people. How people use the application, how many unique visits, how many visits, and, most importantly, what people do and where they do it.



This section is large, filled with useful data. The User Frequency chart shows the time that passes between how a user who has already logged in has left and when he has logged on to your website / application again. If this is an internal site for employees, you can see that everything is fine with them - they return to this site during the day.



New vs. Schedule Returning shows the percentage of new visitors and returned.



Engagement Level is the distribution of activities per session. Activity is when a person goes somewhere in the process, and is not on the same page.



The next item is Authenticated Active Users. Shows the same as the previous item, but for authenticated users. The logic depends on the Telemetry SDK and the developer.

The Loyalty item shows for a certain time the dynamics of user loyalty - how many of them came the first time, how many of those who came came the second time, many times, the duration of the sessions, and so on.



Similar to the Environment item - there will be no new data without the Telemetry SDK. If Features is about the site, Users is about people, then Environment is about what people and the site are connected to — the ecosystem that surrounds any user and that can give valuable information to analytics: operating system, browser, device type, referral (if the user came from a link from another site), language, display resolution, and so on. Sometimes interesting details are found - for example, it may be found that when planning, the screen resolutions up to 1280x640 were discarded, but it turned out that this is still popular among users (an example of a far-fetched one).



If a breakdown by version of a specific system is interesting, everything is available by clicking on the name of the OS.



Screen Resolutions have screen resolutions available.



Browsers are made similar to operating systems - hierarchy browser name-> version.





Global will show the geographical location of users and requests. Not always useful for analytics information, as many users prefer to walk through the resources of other states.



Clicking on the location will lead to a more detailed display - by country. All this is useful when we are writing a global project, and we, for example, are interested in understanding the dynamics of customers coming from specific countries, and concentrating the efforts of sales managers on these countries or regions.



Languages ​​is a language that is registered in requests from users. It is useful when we need to understand which of the Language Pack for our project you need to focus on.



Summary


Application Insights looks like an interesting tool that can be a good assistant for developers working on projects of completely different levels - from local or intranet applications to global corporate projects. Given the fact that AI is free for VSO, in which there are less than five users, this tool is a must-try - all of a sudden it’s not enough in your daily developer kit.

Source: https://habr.com/ru/post/214985/


All Articles