Export (0) Print
Expand All

Monitor your web app's availability and responsiveness

Visual Studio 2013

Application Insights is in preview.

Caution note Caution

This is about the older version of Application Insights in Visual Studio Online. There’s a new version in Microsoft Azure. How do I know which I’m using, and how do I choose?

Is your server still running? Is it responding properly, and fast enough? Microsoft Application Insights tests your web application or website at regular intervals. If the site goes down or responds slowly or incorrectly, you'll receive an email alert. And you'll get graphs showing its availability and responsiveness over time.

Availability and response time graphs

You can set up availability monitoring for any web service, such as a website, or the web component of your phone app. It doesn't matter whether your service is running in Azure or on your premises. It doesn't even have to be your own service. You don't have to alter the web service in any way.

There are two ways to set up an availability test or synthetic monitor:

  • A Single URL test accesses one web page. The test verifies that a response is received from the web server within a standard interval. It can also verify the HTTP return code and perform a simple test on the text content of the web page.

  • A Visual Studio web test accesses a sequence of pages, for example to simulate searching for an item and adding it to a shopping cart.

If you already added Application Insights to your web app, then your application component is already registered in Application Insights.

Go to the Availability page, select your application component, and follow the instructions to set up a simple synthetic monitor.

In Availability, select your application

When the monitor starts running, the setup instructions will be replaced by the test results.

Then you might want to add another single URL monitor, or add a multi-step test.

Normally it’s easiest to add an availability test after you’ve set up usage or performance monitoring for your app. But it is also possible to set up a separate application component that only runs availability tests.

  1. Add an application component and choose to set up website monitoring.

    In Overview, Add application, choose No, Website

  2. Enter an application name for the website and the URL of the site you want to monitor.

    Enter appl name, Create; URL to test, Create.

    Ignore the other steps of the procedure.

  3. Go to the Availability page and select the application you created.

    Select your app and a specific test

The first results will appear in about a minute. Select the specific test to see these results. Processed summary results in the parent node take longer.

Then you might want to add another single URL monitor, or add a multi-step test.

  1. After you’ve set up your first test, add more on the availability page.

    Choose your application and choose +, Single URL
  2. Set the URL you want to monitor.

    Enter the URL of a public web page or service

You might want to refine some of the details of your test.

Select a test and edit it. (Notice that you have to choose a child test, not the parent application.)

Select an availability test and choose Edit

Provide a string that should appear in the page returned from the URL.

Set locations, content test, and alert rule

What are the locations about?

Application Insights sends a request to the website from those locations, in the same way that users will access the site from different parts of the world. If your site becomes unavailable in the USA but still available in Europe, you'll know that the problem is a network issue, rather than in your server.

What HTTP status code should I test for?

Typically you’ll want to test that the HTTP status code equals 200, which signals that the server recognized the URI and returned a page.

Can I use wildcards in the content match string?

No. You can test any plain text.

You can define more than one test for the same application. For example, you could test your site's home page, and also test a page that exercises your site's database, such as a product catalog.

You can monitor a scenario that involves multiple steps. For example, if you are monitoring a sales website, you could test that adding items to the shopping cart works correctly.

To create a multi-step test, you record the scenario by using Visual Studio, and then upload the recording to Application Insights. Application Insights will replay the scenario at intervals and verify the responses.

Use Visual Studio Ultimate to record a user session.

  1. Create a web performance test project.

    In Visual Studio, create a web perf test
  2. Start recording.

    In Visual Studio, record a web test

    Internet Explorer opens, with the web test recorder add-in.

  3. Do the user actions you want to simulate in your test—open your website, and so on. Then stop your test.

    Test recorder sidebar in Internet Explorer.

    Don't make a long scenario. There's a limit of 100 steps and a two-minute timeout.

  4. Run the test in Visual Studio to make sure it works.

    Choose edit.

    The web test runner opens a web browser and repeats the actions you recorded. Make sure it works as you expected.

Your test is recorded in a .webtest file in the Visual Studio project.

(Know all about web tests? OK, here are some things to avoid: Don't insert code for any loops or plug-ins, and don’t include references to other tests.)

  1. On the Availability page for your application, add a web test.

    Choose +, New Visual Studio test
  2. Upload the *.webtest file that you recorded. Choose the geographical locations where you want the test to run, and set the email address for alerts.

    Select at least one location

The Availability page shows a summary of the tests for the application you select. Your new test will show results after about a minute.

Drag across the small summary chart to zoom

How do I zoom in/out?

Drag across part of the small summary graph. You can also change the date range at top right.

How do I know if my server is responding correctly to the tests?

Red crosses represent availability tests that have failed. A test can fail because there was no response, or because the returned page didn't contain the expected content.

Why can’t I open a red cross to see the detailed error report?

First select a specific test such as ‘HomePage’ or ‘ProductCatalog’ – not the whole application. Then you can open the details of specific results.

  • You can hide the results from any individual monitor.

    Select or deselect a test.
  • Select any test to see detailed results.

    Choose a test to see its results.
  • To open the result of that test, choose a red cross or a green dot.

    Download Intellitrace file

    • I’m clicking a red cross but it doesn’t open the test results.

      Make sure you select a specific test (such as ‘HomePage’ in our example). You can’t open the results when you select the whole application such as ‘FabrikamIceCream’.

  • Look at the Details and Results tabs to see the results of the test.

    To see the stack trace in the context of the code, download the result and view it in Visual Studio Ultimate.

© 2014 Microsoft