您现在访问的是微软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. 在 Visual Studio Enterprise 中创建和上传到门户,以便执行多步骤 web 测试。Multi-step web tests are created in Visual Studio Enterprise and uploaded to the portal for execution.
  • 自定义跟踪可用性测试:TrackAvailability()方法可以用于创建您自己的自定义的可用性测试。Custom Track Availability Tests: The TrackAvailability() method can be used to create your own custom availability tests.

您可以创建每个 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 测试"有点用词不当。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.

备注

我们强烈建议您从多个位置测试至少五个不同位置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。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