在 Application Insights 中使用搜尋Using Search in Application Insights

「搜尋」是 Application Insights 的一項功能,可用來尋找及探索個別遙測項目,例如頁面檢視、例外狀況或 Web 要求。Search is a feature of Application Insights that you use to find and explore individual telemetry items, such as page views, exceptions, or web requests. 而您可以檢視所編寫的記錄追蹤和事件。And you can view log traces and events that you have coded.

(若要對您的資料執行更複雜的查詢,請使用分析。)(For more complex queries over your data, use Analytics.)

在 Azure 入口網站In the Azure portal

您可以從應用程式的 [Application Insights 總覽] 索引標籤 (位於頂端列) 或左側的 [調查] 底下開啟診斷搜尋。You can open diagnostic search from the Application Insights Overview tab of your application (located at in the top bar) or under investigate on the left.

搜尋索引標籤

請移至 [事件種類] 下拉式功能表, 以查看遙測專案的清單-伺服器要求、頁面流覽、您已撰寫程式碼的自訂事件等等。Go to the Event types' drop-down menu to see a list of telemetry items- server requests, page views, custom events that you have coded, and so on. 在 [結果] 清單的頂端, 是顯示一段時間內事件計數的摘要圖表。At the top of the results' list, is a summary chart showing counts of events over time.

按一下下拉式功能表或 [重新整理], 以取得新的事件。Click out of the drop-down menu or Refresh to get new events.

在 Visual Studio 中In Visual Studio

在 Visual Studio 中,也有 [Application Insights 搜尋] 視窗。In Visual Studio, there's also an Application Insights Search window. 它最適合顯示您偵錯的應用程式所產生的遙測事件。It's most useful for displaying telemetry events generated by the application that you're debugging. 還可以顯示 Azure 入口網站上從您已發佈的應用程式收集的事件。But it can also show the events collected from your published app at the Azure portal.

在 Visual Studio 中開啟 [搜尋] 視窗:Open the Search window in Visual Studio:

Visual Studio 開啟 Application Insights 搜尋

[搜尋] 視窗有類似 Web 入口網站的功能:The Search window has features similar to the web portal:

Visual Studio Application Insights 搜尋視窗

您開啟要求或頁面檢視時可以看到 [追蹤作業] 索引標籤。The Track Operation tab is available when you open a request or a page view. 「作業」是與單一要求或頁面檢視相關聯的一連串事件。An 'operation' is a sequence of events that is associated with to a single request or page view. 例如,相依性呼叫、例外狀況、追蹤記錄和自訂事件可能都是單一作業的一部分。For example, dependency calls, exceptions, trace logs, and custom events might be part of a single operation. 針對要求或頁面檢視,[追蹤作業] 索引標籤會以圖形顯示這些事件的時刻和持續時間。The Track Operation tab shows graphically the timing and duration of these events in relation to the request or page view.

檢查個別項目Inspect individual items

選取任何遙測項目來查看重要欄位和相關項目。Select any telemetry item to see key fields and related items.

個別相依性要求的螢幕擷取畫面

這將會啟動端對端交易詳細資料檢視。This will launch the end-to-end transaction details view.

篩選事件類型Filter event types

開啟 [事件種類] 下拉式功能表, 然後選擇您想要查看的事件種類。Open the Event types' drop-down menu and choose the event types you want to see. (如果您稍後想要還原篩選, 請按一下 [重設])。(If, later, you want to restore the filters, click Reset.)

事件類型包括:The event types are:

依據屬性值篩選Filter on property values

您可以依屬性的值篩選事件。You can filter events on the values of their properties. 可用的屬性因您所選取的事件類型而定。The available properties depend on the event types you selected. 按一下篩選圖示Click on the filter icon 篩選圖示 以開始。to start.

如果未針對特定屬性選擇任何值,則相當於選擇全部的值。Choosing no values of a particular property has the same effect as choosing all values. 這樣會關掉該屬性的篩選功能。It switches off filtering on that property.

篩選器值右側的計數顯示目前篩選的集合中有多少個出現次數。Notice that the counts to the right of the filter values show how many occurrences there are in the current filtered set.

尋找具有相同屬性的事件Find events with the same property

若要尋找具有相同屬性值的所有專案, 請在搜尋列中輸入, 或在流覽 [篩選] 索引標籤中的屬性時按一下核取方塊。To find all the items with the same property value, either type it into the search bar or click the checkbox when looking through properties in the filter tab.

按一下 [篩選] 索引標籤中屬性的核取方塊

搜尋資料Search the data

注意

若要撰寫更複雜的查詢, 請從 [搜尋] 分頁頂端開啟 [記錄 (分析) ]。To write more complex queries, open Logs (Analytics) from the top of the Search blade.

您可以搜尋任何屬性值中的字詞。You can search for terms in any of the property values. 如果您已撰寫具有屬性值的自訂事件, 這就很有用。This is useful if you have written custom events with property values.

您可能想要設定時間範圍,因為對一小段時間範圍進行的搜尋較快速。You might want to set a time range, as searches over a shorter range are faster.

Open diagnostic search

請搜尋完整單字,而不是子字串。Search for complete words, not substrings. 使用引號來括住的特殊字元。Use quotation marks to enclose special characters.

StringString Not found 已找到Found
HomeController.AboutHomeController.About home
controller
out
homecontroller
about
"homecontroller.about"
美國United States Uni
ted
united
states
united AND states
"united states"

以下是您可以使用搜尋運算式:Here are the search expressions you can use:

範例查詢Sample query 效果Effect
apple 在日期範圍中尋找欄位含有 "apple" 這個字的所有事件Find all events in the time range whose fields include the word "apple"
apple AND banana
apple banana
尋找同時含有這兩個字的事件。Find events that contain both words. 請使用大寫 "AND",而不是 "and"。Use capital "AND", not "and".
簡短格式。Short form.
apple OR banana 尋找含有任一單字的事件。Find events that contain either word. 請使用 "OR",而不是 "or"。Use "OR", not "or".
apple NOT banana 尋找含有一個字但不含另一個字的事件。Find events that contain one word but not the other.

取樣Sampling

如果您的應用程式會產生大量的遙測 (而且您使用 ASP.NET SDK 版本 2.0.0-Beta3 或更新版本), 調適型取樣模組會自動只傳送代表性的事件數, 以減少傳送至入口網站的磁片區。If your app generates a large amount of telemetry (and you are using the ASP.NET SDK version 2.0.0-beta3 or later), the adaptive sampling module automatically reduces the volume that is sent to the portal by sending only a representative fraction of events. 不過,同一個要求相關的事件是以整組方式來選取或取消選取,方便您切換瀏覽相關事件。However, events that are related to the same request are selected or deselected as a group, so that you can navigate between related events.

了解取樣Learn about sampling.

建立工作項目Create work item

您可以利用來自任何遙測項目的詳細資料,在 GitHub 或 Azure DevOps 中建立 Bug。You can create a bug in GitHub or Azure DevOps with the details from any telemetry item.

按一下任何遙測專案, 然後選取 [建立工作專案], 移至端對端交易詳細資料檢視。Go to the end-to-end transaction detail view by clicking on any telemetry item then select Create work item.

按一下 [新增工作項目]、編輯欄位,然後按一下 [確定]。

當您第一次執行此動作時,系統會要求您設定與 Azure DevOps 組織和專案的連結。The first time you do this, you are asked to configure a link to your Azure DevOps organization and project.

(您也可以在 [工作專案] 索引標籤上設定連結)。(You can also configure the link on the Work Items tab.)

傳送更多遙測到 Application InsightsSend more telemetry to Application Insights

除了 Application Insights SDK 傳送的內建遙測,您可以:In addition to the out-of-the-box telemetry sent by Application Insights SDK, you can:

  • .NETJava 中,從您最喜愛的紀錄架構擷取記錄追蹤。Capture log traces from your favorite logging framework in .NET or Java. 這表示您可以搜尋您的記錄追蹤,並將它們與頁面檢視、例外狀況和其他事件相互關聯。This means you can search through your log traces and correlate them with page views, exceptions, and other events.
  • 編寫程式碼以傳送自訂事件、頁面檢視和例外狀況。Write code to send custom events, page views, and exceptions.

了解如何將記錄和自訂遙測傳送至 Application InsightsLearn how to send logs and custom telemetry to Application Insights.

問與答Q & A

保留多少資料?How much data is retained?

請參閱限制摘要See the Limits summary.

我如何查看我的伺服器要求中的 POST 資料?How can I see POST data in my server requests?

我們不會自動記錄 POST 資料,但您可以使用 TrackTrace 或記錄呼叫We don't log the POST data automatically, but you can use TrackTrace or log calls. 將 POST 資料放在訊息參數中。Put the POST data in the message parameter. 您無法像篩選屬性一樣來篩選訊息,但大小限制比較長。You can't filter on the message in the same way you can filter on properties, but the size limit is longer.

接續步驟Next steps