您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

监视任何网站的可用性Monitor the availability of any website

部署 web 应用/网站之后,可以设置重复测试来监视可用性和响应能力。After you've deployed your web app/website, you can set up recurring tests to monitor availability and responsiveness. Azure Application Insights 将来自全球各地的 Web 请求定期发送到应用程序。Azure Application Insights sends web requests to your application at regular intervals from points around the world. 如果你的应用程序未响应,或响应速度太慢,则会发出警报。It can alert you if your application isn't responding, or if it responds too slowly.

对于可以从公共 Internet 访问的任何 HTTP 或 HTTPS 终结点,均可设置可用性测试。You can set up availability tests for any HTTP or HTTPS endpoint that is accessible from the public internet. 您无需对正在测试的网站进行任何更改。You don't have to make any changes to the website you're testing. 事实上,它甚至无需成为你拥有的站点。In fact, it doesn't even have to be a site you own. 可以测试服务所依赖的 REST API 的可用性。You can test the availability of a REST API that your service depends on.

可用性测试的类型:Types of availability tests:

有三种类型的可用性测试:There are three types of availability tests:

  • URL ping 测试:可以在 Azure 门户中创建的简单测试。URL ping test: a simple test that you can create in the Azure portal.
  • 多步骤 web 测试:记录一系列 web 请求,可以播放这些请求来测试更复杂的方案。Multi-step web test: A recording of a sequence of web requests, which can be played back to test more complex scenarios. 多步骤 web 测试在 Visual Studio Enterprise 中创建并上载到门户以执行。Multi-step web tests are created in Visual Studio Enterprise and uploaded to the portal for execution.
  • 自定义跟踪可用性测试:如果你决定创建自定义应用程序以运行可用性测试,则可以使用 TrackAvailability() 方法将结果发送到 Application Insights。Custom Track Availability Tests: If you decide to create a custom application to run availability tests, the TrackAvailability() method can be used to send the results to Application Insights.

对于每个 Application Insights 资源,最多可以创建100个可用性测试。You can create up to 100 availability tests per Application Insights resource.

创建 Application Insights 资源Create an Application Insights resource

若要创建可用性测试,首先需要创建一个 Application Insights 资源。In order to create an availability test, you first need to create an Application Insights resource. 如果已创建资源,请转到下一节,创建 URL Ping 测试If you have already created a resource, proceed to the next section to create a URL Ping test.

从 "Azure 门户中,选择"创建资源" > 开发人员工具 > " Application Insights创建 Application Insights 资源From the Azure portal, select Create a resource > Developer Tools > Application Insights and create an Application Insights resource.

创建 URL ping 测试Create a URL ping test

名称 "URL ping 测试" 是 misnomer 的一个小数位。The name "URL ping test" is a bit of a misnomer. 为清楚起见,此测试不会将 ICMP (Internet 控制消息协议)用于检查站点的可用性。To be clear, this test is not making any use of ICMP (Internet Control Message Protocol) to check your site's availability. 而是使用更高级的 HTTP 请求功能来验证终结点是否正在响应。Instead it uses more advanced HTTP request functionality to validate whether an endpoint is responding. 它还测量与该响应关联的性能,并添加设置自定义成功条件和更高级功能(例如分析从属请求和允许重试)的功能。It also measures the performance associated with that response, and adds the ability to set custom success criteria coupled with more advanced features like parsing dependent requests, and allowing for retries.

若要创建第一个可用性请求,请打开 "可用性" 窗格并选择 "创建测试"。To create your first availability request, open the Availability pane and select Create Test.

至少填写网站的 URL

创建测试Create a test

设置Setting 说明Explanation
URLURL URL 可以是要测试的任何网页,但必须从公共 internet 中查看。The URL can be any web page you want to test, but it must be visible from the public internet. 该 URL 可以包括查询字符串。The URL can include a query string. 因此,例如,可以稍微训练一下数据库。So, for example, you can exercise your database a little. 如果 URL 解析为重定向,最多可以跟踪 10 个重定向。If the URL resolves to a redirect, we follow it up to 10 redirects.
分析从属请求Parse dependent requests 测试请求图像、脚本、样式文件以及其他属于受测网页的文件。Test requests images, scripts, style files, and other files that are part of the web page under test. 记录的响应时间包括获取这些文件所耗费的时间。The recorded response time includes the time taken to get these files. 如果在整个测试的超时时间内无法成功下载这些资源中的任何资源,则测试将失败。The test fails if any of these resources cannot be successfully downloaded within the timeout for the whole test. 如果不选中此选项,则测试只请求指定 URL 的文件。If the option is not checked, the test only requests the file at the URL you specified. 启用此选项将导致更严格的检查。Enabling this option results in a stricter check. 在手动浏览站点时,测试可能会失败,这可能不明显。The test could fail for cases, which may not be noticeable when manually browsing the site.
启用重试Enable retries 如果测试失败,则会在短时间间隔后重试。when the test fails, it is retried after a short interval. 仅当连续三次尝试失败时,才报告失败。A failure is reported only if three successive attempts fail. 然后,将按照一般的测试频率执行后续测试。Subsequent tests are then performed at the usual test frequency. 重试会暂停,直到下次成功为止。Retry is temporarily suspended until the next success. 可在每个测试位置单独应用此规则。This rule is applied independently at each test location. 建议选择此选项We recommend this option. 平均大约有 80% 的失败可在重试后消除。On average, about 80% of failures disappear on retry.
测试频率Test frequency 设置从每个测试位置运行测试的频率。Sets how often the test is run from each test location. 如果有五个测试位置,且默认频率为五分钟,则平均每隔一分钟测试站点一次。With a default frequency of five minutes and five test locations, your site is tested on average every minute.
测试位置Test locations 是指服务器将 web 请求发送到 URL 的位置。Are the places from where our servers send web requests to your URL. 建议的最小测试位置数为 5 ,以确保可以将网站中的问题与网络问题区分开来。Our minimum number of recommended test locations is five in order to insure that you can distinguish problems in your website from network issues. 最多可以选择 16 个位置。You can select up to 16 locations.

如果你的 URL 在公共 internet 上不可见,则可以选择有选择地打开防火墙,只允许测试事务通过If your URL is not visible from the public internet, you can choose to selectively open up your firewall to allow only the test transactions through. 若要了解有关我们的可用性测试代理的防火墙例外的详细信息,请参阅IP 地址指南To learn more about the firewall exceptions for our availability test agents, consult the IP address guide.

备注

我们强烈建议从多个位置进行测试,最少使用 5个位置。We strongly recommend testing from multiple locations with a minimum of five locations. 这是为了防止可能由特定位置的暂时性问题导致的虚假警报。This is to prevent false alarms that may result from transient issues with a specific location. 此外,我们发现,最佳配置是将测试位置数等于警报位置阈值 + 2In addition we have found that the optimal configuration is to have the number of test locations be equal to the alert location threshold + 2.

成功条件Success criteria

设置Setting 说明Explanation
测试超时Test timeout 减少此值可以接收有关响应变慢的警报。Decrease this value to be alerted about slow responses. 如果未在这段时间内收到站点的响应,则将测试视为失败。The test is counted as a failure if the responses from your site have not been received within this period. 如果选择了“分析依赖请求”,则必须在这段时间内收到所有图像、样式文件、脚本和其他依赖资源。If you selected Parse dependent requests, then all the images, style files, scripts, and other dependent resources must have been received within this period.
HTTP 响应HTTP response 视为成功的返回状态代码。The returned status code that is counted as a success. 代码 200 指示返回了正常网页。200 is the code that indicates that a normal web page has been returned.
内容匹配Content match 字符串,如 "欢迎!"A string, like "Welcome!" 我们测试区分大小写的匹配项是否出现在每个响应中。We test that an exact case-sensitive match occurs in every response. 它必须是不带通配符的纯字符串。It must be a plain string, without wildcards. 别忘了,如果页面内容更改,可能需要更新。Don't forget that if your page content changes you might have to update it. 内容匹配仅支持英文字符Only English characters are supported with content match

警报Alerts

设置Setting 说明Explanation
近乎实时(预览)Near-realtime (Preview) 建议使用近乎实时的警报。We recommend using Near-realtime alerts. 创建可用性测试后,配置此类型的警报。Configuring this type of alert is done after your availability test is created.
经典Classic 我们不再建议使用经典警报来执行新的可用性测试。We no longer recommended using classic alerts for new availability tests.
警报位置阈值Alert location threshold 建议最少 3/5 个位置。We recommend a minimum of 3/5 locations. 警报位置阈值和测试位置数量之间的最佳关系是警报位置阈值 = 测试位置数-2,最少有5个测试位置。The optimal relationship between alert location threshold and the number of test locations is alert location threshold = number of test locations - 2, with a minimum of five test locations.

查看可用性测试结果See your availability test results

可通过折线图和散点图视图对可用性测试结果进行可视化。Availability test results can be visualized with both line and scatter plot views.

几分钟后,单击 "刷新" 以查看测试结果。After a few minutes, click Refresh to see your test results.

行视图

散点图视图显示了其中包含诊断测试步骤详细信息的测试结果的示例。The scatterplot view shows samples of the test results that have diagnostic test-step detail in them. 测试引擎存储已失败的测试的诊断详细信息。The test engine stores diagnostic detail for tests that have failures. 对于成功的测试,将存储执行子集的诊断详细信息。For successful tests, diagnostic details are stored for a subset of the executions. 将鼠标悬停在任何绿色/红色点上可查看测试、测试名称和位置。Hover over any of the green/red dots to see the test, test name, and location.

行视图

选择特定测试、位置或减少时间段,可查看围绕感兴趣的时间段的更多结果。Select a particular test, location, or reduce the time period to see more results around the time period of interest. 使用搜索资源管理器以查看所有执行结果,或者使用分析查询以针对此数据运行自定义报告。Use Search Explorer to see results from all executions, or use Analytics queries to run custom reports on this data.

检查和编辑测试Inspect and edit tests

若要编辑、暂时禁用或删除测试,请单击测试名称旁的省略号。To edit, temporarily disable, or delete a test click the ellipses next to a test name. 进行更改后,将配置更改传播到所有测试代理可能需要长达20分钟的时间。It may take up to 20 minutes for configuration changes to propagate to all test agents after a change is made.

查看测试详细信息。

对服务执行维护时,可能需要禁用可用性测试或与这些测试关联的警报规则。You might want to disable availability tests or the alert rules associated with them while you are performing maintenance on your service.

如果出现故障If you see failures

单击红点。Click a red dot.

单击红点

从可用性测试结果中,可以看到所有组件的事务详细信息。From an availability test result, you can see the transaction details across all components. 在此门户中,可以:Here you can:

  • 检查从服务器收到的响应。Inspect the response received from your server.
  • 使用在处理失败的可用性测试时收集的相关服务器端遥测数据进行故障诊断。Diagnose failure with correlated server-side telemetry collected while processing the failed availability test.
  • 在 Git 或 Azure Boards 中记录问题或工作项以跟踪问题。Log an issue or work item in Git or Azure Boards to track the problem. Bug 中将包含转至此事件的链接。The bug will contain a link to this event.
  • 在 Visual Studio 中打开 Web 测试结果。Open the web test result in Visual Studio.

此处详细了解端到端事务诊断体验。Learn more about the end to end transaction diagnostics experience here.

单击异常行可查看导致综合可用性测试失败的服务器端异常的详细信息。Click on the exception row to see the details of the server-side exception that caused the synthetic availability test to fail. 还可以获取调试快照,进行更丰富的代码级诊断。You can also get the debug snapshot for richer code level diagnostics.

服务器端诊断

除了原始结果外,还可以在指标资源管理器中查看两个关键可用性指标:In addition to the raw results, you can also view two key Availability metrics in Metrics Explorer:

  1. 可用性:已成功的测试占执行的所有测试的百分比。Availability: Percentage of the tests that were successful, across all test executions.
  2. 测试持续时间:执行的所有测试的平均测试持续时间。Test Duration: Average test duration across all test executions.

自动化Automation

故障排除Troubleshooting

专用故障排除文章Dedicated troubleshooting article.

后续步骤Next steps