監視任何網站的可用性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.

您可以為公用網際網路可存取的任何 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()可以用來建立您自己的自訂可用性測試。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 測試」這個名稱有點 misnomer。The name "URL ping test" is a bit of a misnomer. 為了清楚說明,這項測試不會使用 ICMP (網際網路控制訊息通訊協定)來檢查網站的可用性。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.

Fill at least the URL of your website

建立測試Create a test

設定Setting 說明Explanation
URLURL 此 URL 可以是任何您想要測試的網頁,但必須可從公用網際網路看到。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. 預設頻率為 5 分鐘且有五個測試位置,則您的網站平均每一分鐘會執行測試。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 在公用網際網路中看不到,您可以選擇選擇性地開啟防火牆,只允許透過的測試交易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 是表示已傳回標準 Web 網頁的代碼。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