部署適用于內部部署伺服器的 Azure 監視器 Application Insights 代理程式
- 發行項
Application Insights 代理程式(先前稱為狀態監視器 V2)是發佈至PowerShell 資源庫 的 PowerShell 模組。 它會取代狀態監視器。 遙測會傳送至Azure 入口網站,您可以在 其中監視 您的應用程式。
如需支援自動結構案例的完整清單,請參閱 支援的環境、語言和資源提供者 。
注意
模組目前支援無程式碼檢測裝載于 IIS 的 ASP.NET 和 ASP.NET Core Web 應用程式。 使用 SDK 來檢測 JAVA 和 Node.js 應用程式。
PowerShell 資源庫
Application Insights 代理程式位於 PowerShell 資源庫 。
指示
- 若要開始使用簡潔的程式碼範例,請參閱 開始使用索引 標籤。
- 如需如何開始使用的深入探討,請參閱 詳細指示索引標籤 。
- 如需 PowerShell API 參考,請參閱 API 參考 索引 標籤。
- 如需版本資訊更新,請參閱 版本資訊 索引標籤。
此索引標籤包含預期適用于大部分環境的快速入門命令。 指示取決於PowerShell 資源庫來散發更新。 這些命令支援 PowerShell -Proxy
參數。
如需這些命令的說明、自訂指示,以及疑難排解的相關資訊,請參閱 詳細指示 。
如尚未擁有 Azure 訂用帳戶,請在開始之前先建立免費帳戶。
透過 PowerShell 資源庫 下載並安裝
使用PowerShell 資源庫進行下載和安裝。
安裝先決條件
若要啟用監視,您必須有連接字串。 連接字串會顯示在 Application Insights 資源的 [概觀] 窗格中。 如需詳細資訊,請參閱 連線ion 字串 。
以系統管理員身分執行 PowerShell。
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Install-Module -Name PowerShellGet -Force
關閉 PowerShell。
安裝 Application Insights 代理程式
以系統管理員身分執行 PowerShell。
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
Install-Module -Name Az.ApplicationMonitor -AllowPrerelease -AcceptLicense
啟用監視
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
Enable-ApplicationInsightsMonitoring -ConnectionString 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/'
手動下載並安裝 (離線選項)
您也可以手動下載並安裝。
下載模組
從 PowerShell 資源庫 手動下載最新版本的模組 。
解壓縮並安裝 Application Insights 代理程式
$pathToNupkg = "C:\Users\t\Desktop\Az.ApplicationMonitor.0.3.0-alpha.nupkg"
$pathToZip = ([io.path]::ChangeExtension($pathToNupkg, "zip"))
$pathToNupkg | rename-item -newname $pathToZip
$pathInstalledModule = "$Env:ProgramFiles\WindowsPowerShell\Modules\Az.ApplicationMonitor"
Expand-Archive -LiteralPath $pathToZip -DestinationPath $pathInstalledModule
啟用監視
Enable-ApplicationInsightsMonitoring -ConnectionString 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/'
此索引標籤描述如何上線至PowerShell 資源庫並下載 ApplicationMonitor 模組。 包含的是您需要開始使用的最常見參數。 我們也提供手動下載指示,以防您沒有網際網路存取權。
取得連接字串
若要開始使用,您需要連接字串。 如需詳細資訊,請參閱 連線ion 字串 。
使用提升許可權的執行原則,以管理員身分執行 PowerShell
以管理員身分執行
PowerShell 需要管理員istrator 層級的許可權,才能變更您的電腦。
執行原則
- 描述:根據預設,會停用執行 PowerShell 腳本。 我們建議只允許目前範圍的 RemoteSigned 腳本。
- 參考: 關於執行原則 和 Set-ExecutionPolicy 。
- 命令:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
。 - 選擇性參數:
-Force
. 略過確認提示。
範例錯誤
Install-Module : The 'Install-Module' command was found in the module 'PowerShellGet', but the module could not be
loaded. For more information, run 'Import-Module PowerShellGet'.
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot
be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
PowerShell 的先決條件
執行 $PSVersionTable
命令來稽核 PowerShell 的實例。
此命令會產生下列輸出:
Name Value
---- -----
PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
這些指示是在執行 Windows 10 和下列版本的電腦上撰寫和測試的。
PowerShell 資源庫的必要條件
這些步驟會準備您的伺服器,以從PowerShell 資源庫下載模組。
注意
Windows 10、Windows Server 2016 和 PowerShell 6+ 支援PowerShell 資源庫。 如需舊版的相關資訊,請參閱 安裝 PowerShellGet 。
使用提升許可權的執行原則,以管理員執行 PowerShell。
安裝 NuGet 套件提供者。
- 描述:您需要此提供者才能與 NuGet 型存放庫互動,例如PowerShell 資源庫。
- 參考: Install-PackageProvider 。
- 命令:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201
。 - 選擇性參數:
-Proxy
. 指定要求的 Proxy 伺服器。-Force
. 略過確認提示。
如果未設定 NuGet,您會收到此提示:
NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\t\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
將PowerShell 資源庫設定為受信任的存放庫。
- 描述:根據預設,PowerShell 資源庫是不受信任的存放庫。
- 參考: Set-PSRepository 。
- 命令:
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
。 - 選擇性參數:
-Proxy
. 指定要求的 Proxy 伺服器。
如果PowerShell 資源庫不受信任,您會收到此提示:
Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
您可以執行 命令來確認這項變更並稽核
Get-PSRepository
全部PSRepositories
。安裝最新版的 PowerShellGet。
- 描述:此模組包含用來從PowerShell 資源庫取得其他模組的工具。 版本 1.0.0.1 隨附于 Windows 10 和 Windows Server。 需要 1.6.0 版或更高版本。 若要判斷已安裝的版本,請
Get-Command -Module PowerShellGet
執行 命令。 - 參考: 安裝 PowerShellGet 。
- 命令:
Install-Module -Name PowerShellGet
。 - 選擇性參數:
-Proxy
. 指定要求的 Proxy 伺服器。-Force
. 略過「已安裝」警告,並安裝最新版本。
如果您未使用最新版的 PowerShellGet,您會收到此錯誤:
Install-Module : A parameter cannot be found that matches parameter name 'AllowPrerelease'. At line:1 char:20 Install-Module abc -AllowPrerelease ~~~~~~~~~~~~~~~~ CategoryInfo : InvalidArgument: (:) [Install-Module], ParameterBindingException FullyQualifiedErrorId : NamedParameterNotFound,Install-Module
- 描述:此模組包含用來從PowerShell 資源庫取得其他模組的工具。 版本 1.0.0.1 隨附于 Windows 10 和 Windows Server。 需要 1.6.0 版或更高版本。 若要判斷已安裝的版本,請
重新開機 PowerShell。 您無法在目前的會話中載入新版本。 新的 PowerShell 會話會載入最新版的 PowerShellGet。
透過 PowerShell 資源庫 下載並安裝模組
這些步驟會從 PowerShell 資源庫 下載 Az.ApplicationMonitor 模組。
- 請確定符合PowerShell 資源庫的所有必要條件。
- 使用提升許可權的執行原則,以管理員執行 PowerShell。
- 安裝 Az.ApplicationMonitor 模組。
- 參考: Install-Module 。
- 命令:
Install-Module -Name Az.ApplicationMonitor
。 - 選擇性參數:
-Proxy
. 指定要求的 Proxy 伺服器。-AllowPrerelease
. 允許安裝 Alpha 和 Beta 版本。-AcceptLicense
. 略過 「接受授權」提示-Force
. 略過「未受信任的存放庫」警告。
手動下載並安裝模組 (離線選項)
如果基於任何原因而無法連線到 PowerShell 模組,您可以手動下載並安裝 Az.ApplicationMonitor 模組。
手動下載最新的 nupkg 檔案
- 移至 https://www.powershellgallery.com/packages/Az.ApplicationMonitor。
- 在 [版本歷程記錄 ] 資料表中 選取最新版本的檔案。
- 在 [安裝選項] 底下 ,選取 [ 手動下載 ]。
選項 1:安裝至 PowerShell 模組目錄
將手動下載的 PowerShell 模組安裝到 PowerShell 目錄,讓 PowerShell 會話可以探索。 如需詳細資訊,請參閱 安裝 PowerShell 模組 。
使用 Expand-Archive 將 nupkg 解壓縮為 zip 檔案 (v1.0.1.0)
描述:Microsoft.PowerShell.Archive 的基底版本 (v1.0.1.0) 無法解壓縮 nupkg 檔案。 使用 .zip 副檔名重新命名檔案。
參考: Expand-Archive 。
命令:
$pathToNupkg = "C:\az.applicationmonitor.0.3.0-alpha.nupkg" $pathToZip = ([io.path]::ChangeExtension($pathToNupkg, "zip")) $pathToNupkg | rename-item -newname $pathToZip $pathInstalledModule = "$Env:ProgramFiles\WindowsPowerShell\Modules\az.applicationmonitor" Expand-Archive -LiteralPath $pathToZip -DestinationPath $pathInstalledModule
使用 Expand-Archive 解壓縮 nupkg (v1.1.0.0)
描述:使用目前版本的 Expand-Archive 將 nupkg 檔案解壓縮,而不需變更副檔名。
命令:
$pathToNupkg = "C:\az.applicationmonitor.0.2.1-alpha.nupkg" $pathInstalledModule = "$Env:ProgramFiles\WindowsPowerShell\Modules\az.applicationmonitor" Expand-Archive -LiteralPath $pathToNupkg -DestinationPath $pathInstalledModule
選項 2:手動解壓縮並匯入 nupkg
將手動下載的 PowerShell 模組安裝到 PowerShell 目錄,讓 PowerShell 會話可以探索。 如需詳細資訊,請參閱 安裝 PowerShell 模組 。
如果您要將模組安裝到任何其他目錄,請使用 Import-Module 手動匯入模組。
重要
DLL 會透過相對路徑安裝。 將套件的內容儲存在預定的執行時間目錄中,並確認存取權限允許讀取但不寫入。
- 將延伸模組變更為 「.zip」,並將套件的內容解壓縮到您預期的安裝目錄中。
- 尋找 Az.ApplicationMonitor.psd1 的檔案路徑。
- 使用提升許可權的執行原則,以管理員執行 PowerShell。
- 使用
Import-Module Az.ApplicationMonitor.psd1
命令載入模組。
透過 Proxy 路由傳送流量
當您監視私人內部網路上的電腦時,您必須透過 Proxy 路由傳送 HTTP 流量。
從 PowerShell 資源庫 下載並安裝 Az.ApplicationMonitor 的 PowerShell 命令支援 -Proxy
參數。
撰寫安裝腳本時,請檢閱上述指示。
Application Insights SDK 必須將應用程式的遙測傳送給 Microsoft。 建議您在 web.config 檔案中設定應用程式的 Proxy 設定。 如需詳細資訊,請參閱 如何?達到 Proxy 傳遞? 。
啟用監視
Enable-ApplicationInsightsMonitoring
使用 命令來啟用監視。
此索引標籤描述下列 Cmdlet,這些 Cmdlet 是 Az.ApplicationMonitor PowerShell 模組 的成員 :
- Enable-InstrumentationEngine
- Enable-ApplicationInsightsMonitoring
- Disable-InstrumentationEngine
- Disable-ApplicationInsightsMonitoring
- Get-ApplicationInsightsMonitoringConfig
- Get-ApplicationInsightsMonitoringStatus
- Set-ApplicationInsightsMonitoringConfig
- Start-ApplicationInsightsMonitoringTrace
注意
- 若要開始使用,您需要連接字串。 如需詳細資訊,請參閱 建立資源 。
- 此 Cmdlet 會要求您檢閱並接受我們的授權和隱私權聲明。
重要
此 Cmdlet 需要具有管理員許可權和提升許可權的執行原則的 PowerShell 會話。 如需詳細資訊,請參閱 使用提升許可權的執行原則 以系統管理員身分執行 PowerShell。
- 此 Cmdlet 會要求您檢閱並接受我們的授權和隱私權聲明。
- 檢測引擎會增加額外的額外負荷,且預設為關閉。
Enable-InstrumentationEngine
藉由設定一些登錄機碼來啟用檢測引擎。 重新開機 IIS,讓變更生效。
檢測引擎可以補充 .NET SDK 所收集的資料。 它會收集描述 Managed 進程執行的事件和訊息。 這些事件和訊息包括相依性結果碼、HTTP 動詞和 SQL 命令文字 。
如果下列專案,請啟用檢測引擎:
- 您已使用 Enable Cmdlet 啟用監視,但未啟用檢測引擎。
- 您已使用 .NET SDK 手動檢測應用程式,並想要收集額外的遙測。
範例
Enable-InstrumentationEngine
參數
-AcceptLicense
選擇性。 使用此參數可接受無周邊安裝中的授權和隱私權聲明。
-詳細
一般參數。 使用此參數來輸出詳細記錄。
輸出
成功啟用檢測引擎的範例輸出
Configuring IIS Environment for instrumentation engine...
Configuring registry for instrumentation engine...
Enable-ApplicationInsightsMonitoring
在目的電腦上啟用 IIS 應用程式的無程式碼附加監視。
此 Cmdlet 會修改 IIS 應用程式Host.config,並設定一些登錄機碼。 它會建立 applicationinsights.ikey.config 檔案,其會定義每個應用程式所使用的檢測金鑰。 IIS 會在啟動時載入 RedfieldModule,這會在應用程式啟動時將 Application Insights SDK 插入應用程式。 重新開機 IIS,讓變更生效。
啟用監視之後,建議您使用 即時計量 來快速檢查您的應用程式是否傳送遙測資料。
範例
單一連接字串範例
在此範例中,目前電腦上的所有應用程式都會指派單一連接字串。
Enable-ApplicationInsightsMonitoring -ConnectionString 'InstrumentationKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/'
單一檢測金鑰的範例
在此範例中,目前電腦上的所有應用程式都會指派單一檢測金鑰。
Enable-ApplicationInsightsMonitoring -InstrumentationKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
檢測金鑰組應的範例
在此範例中:
MachineFilter
使用'.*'
萬用字元比對目前電腦。AppFilter='WebAppExclude'
null
提供檢測金鑰。 未檢測指定的應用程式。AppFilter='WebAppOne'
將指定的應用程式指派為唯一的檢測金鑰。AppFilter='WebAppTwo'
將指定的應用程式指派為唯一的檢測金鑰。AppFilter
會'.*'
使用萬用字元來比對它尚未相符的任何 Web 應用程式,並指派預設檢測金鑰。- 新增空格以取得可讀性。
Enable-ApplicationInsightsMonitoring -InstrumentationKeyMap `
` @(@{MachineFilter='.*';AppFilter='WebAppExclude'},
` @{MachineFilter='.*';AppFilter='WebAppOne';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1'}},
` @{MachineFilter='.*';AppFilter='WebAppTwo';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2'}},
` @{MachineFilter='.*';AppFilter='.*';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxdefault'}})
注意
此內容中的 AppFilter 命名可能會造成混淆, AppFilter
請在 IIS 上設定應用程式名稱 RegEx 篩選準則(IIS 上的 .NET 時為 HostingEnvironment.SiteName)。 VirtualPathFilter
會在 IIS 上的 .NET 的情況下設定虛擬路徑 RegEx 篩選準則 (HostingEnvironment.ApplicationVirtualPath)。 若要檢測單一應用程式,您可以使用 VirtualPathFilter,如下所示: Enable-ApplicationInsightsMonitoring -InstrumentationKeyMap @(@{VirtualPathFilter="^/MyAppName$"; InstrumentationSettings=@{InstrumentationKey='<your ikey>'}})
參數
-連線ionString
必要。 使用此參數提供單一連接字串供目的電腦上的所有應用程式使用。
-InstrumentationKey
必要。 使用此參數來提供單一檢測金鑰,以供目的電腦上的所有應用程式使用。
-InstrumentationKeyMap
必要。 使用此參數來提供多個檢測金鑰,以及每個應用程式所使用的檢測金鑰組應。
您可以藉由設定 MachineFilter
來建立數部電腦的單一安裝腳本。
重要
應用程式會依規則提供的順序,比對規則。 因此,您應該先指定最特定的規則,最後指定最泛型的規則。
結構描述
@(@{MachineFilter='.*';AppFilter='.*';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}})
- MachineFilter 是電腦或 VM 名稱的必要 C# RegEx。
- '.*' 符合所有專案
- 'ComputerName' 只會比對指定確切名稱的電腦。
- AppFilter 是 IIS 網站名稱的必要 C# RegEx。 您可以執行 get-iissite 命令 ,以取得伺服器上的網站清單。
- '.*' 符合所有專案
- 'SiteName' 只會比對指定確切名稱的 IIS 網站。
- 必須有 InstrumentationKey ,才能監視符合上述兩個篩選準則的應用程式。
- 如果您想要定義規則以排除監視,請將此值保留為 null。
-EnableInstrumentationEngine
選擇性。 使用此參數可讓檢測引擎收集有關 Managed 進程執行期間所發生狀況的事件和訊息。 這些事件和訊息包括相依性結果碼、HTTP 動詞和 SQL 命令文字。
檢測引擎會增加額外負荷,且預設為關閉。
-AcceptLicense
選擇性。 使用此參數可接受無周邊安裝中的授權和隱私權聲明。
-IgnoreSharedConfig
當您有 Web 服務器的叢集時,可能會使用 共用組態 。 HttpModule 無法插入此共用組態。 此腳本失敗,並出現需要額外安裝步驟的訊息。 使用此參數忽略這項檢查並繼續安裝必要條件。 如需詳細資訊,請參閱 已知的 conflict-with-iis-shared-configuration
-詳細
一般參數。 使用此參數可顯示詳細的記錄。
-WhatIf
一般參數。 使用此參數來測試和驗證您的輸入參數,而不需要實際啟用監視。
輸出
成功啟用的範例輸出
Initiating Disable Process
Applying transformation to 'C:\Windows\System32\inetsrv\config\applicationHost.config'
'C:\Windows\System32\inetsrv\config\applicationHost.config' backed up to 'C:\Windows\System32\inetsrv\config\applicationHost.config.backup-2019-03-26_08-59-52z'
in :1,237
No element in the source document matches '/configuration/location[@path='']/system.webServer/modules/add[@name='ManagedHttpModuleHelper']'
Not executing RemoveAll (transform line 1, 546)
Transformation to 'C:\Windows\System32\inetsrv\config\applicationHost.config' was successfully applied. Operation: 'disable'
GAC Module will not be removed, since this operation might cause IIS instabilities
Configuring IIS Environment for codeless attach...
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WAS[Environment]
Configuring IIS Environment for instrumentation engine...
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WAS[Environment]
Configuring registry for instrumentation engine...
Successfully disabled Application Insights Agent
Installing GAC module 'C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\0.2.0\content\Runtime\Microsoft.AppInsights.IIS.ManagedHttpModuleHelper.dll'
Applying transformation to 'C:\Windows\System32\inetsrv\config\applicationHost.config'
Found GAC module Microsoft.AppInsights.IIS.ManagedHttpModuleHelper.ManagedHttpModuleHelper, Microsoft.AppInsights.IIS.ManagedHttpModuleHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
'C:\Windows\System32\inetsrv\config\applicationHost.config' backed up to 'C:\Windows\System32\inetsrv\config\applicationHost.config.backup-2019-03-26_08-59-52z_1'
Transformation to 'C:\Windows\System32\inetsrv\config\applicationHost.config' was successfully applied. Operation: 'enable'
Configuring IIS Environment for codeless attach...
Configuring IIS Environment for instrumentation engine...
Configuring registry for instrumentation engine...
Updating app pool permissions...
Successfully enabled Application Insights Agent
Disable-InstrumentationEngine
藉由移除某些登錄機碼來停用檢測引擎。 重新開機 IIS,讓變更生效。
範例
Disable-InstrumentationEngine
參數
-詳細
一般參數。 使用此參數來輸出詳細記錄。
輸出
成功停用檢測引擎的範例輸出
Configuring IIS Environment for instrumentation engine...
Registry: removing 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN[Environment]'
Registry: removing 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC[Environment]'
Registry: removing 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WAS[Environment]'
Configuring registry for instrumentation engine...
Disable-ApplicationInsightsMonitoring
停用目的電腦上的監視。 此 Cmdlet 會移除 IIS 應用程式的編輯Host.config,並移除登錄機碼。
範例
Disable-ApplicationInsightsMonitoring
參數
-詳細
一般參數。 使用此參數可顯示詳細的記錄。
輸出
成功停用監視的範例輸出
Initiating Disable Process
Applying transformation to 'C:\Windows\System32\inetsrv\config\applicationHost.config'
'C:\Windows\System32\inetsrv\config\applicationHost.config' backed up to 'C:\Windows\System32\inetsrv\config\applicationHost.config.backup-2019-03-26_08-59-00z'
in :1,237
No element in the source document matches '/configuration/location[@path='']/system.webServer/modules/add[@name='ManagedHttpModuleHelper']'
Not executing RemoveAll (transform line 1, 546)
Transformation to 'C:\Windows\System32\inetsrv\config\applicationHost.config' was successfully applied. Operation: 'disable'
GAC Module will not be removed, since this operation might cause IIS instabilities
Configuring IIS Environment for codeless attach...
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WAS[Environment]
Configuring IIS Environment for instrumentation engine...
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC[Environment]
Registry: skipping non-existent 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WAS[Environment]
Configuring registry for instrumentation engine...
Successfully disabled Application Insights Agent
Get-ApplicationInsightsMonitoringConfig
取得組態檔,並將值列印至主控台。
範例
Get-ApplicationInsightsMonitoringConfig
參數
不需要參數。
輸出
讀取組態檔的範例輸出
RedfieldConfiguration:
Filters:
0)InstrumentationKey: AppFilter: WebAppExclude MachineFilter: .*
1)InstrumentationKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2 AppFilter: WebAppTwo MachineFilter: .*
2)InstrumentationKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxdefault AppFilter: .* MachineFilter: .*
Get-ApplicationInsightsMonitoringStatus
此 Cmdlet 提供 Application Insights 代理程式的疑難排解資訊。 使用此 Cmdlet 來調查監視狀態、PowerShell 模組的版本,以及檢查執行中的進程。 此 Cmdlet 會報告監視所需金鑰檔案的版本資訊和資訊。
範例
範例:應用程式狀態
執行 命令 Get-ApplicationInsightsMonitoringStatus
以顯示網站的監視狀態。
Get-ApplicationInsightsMonitoringStatus
IIS Websites:
SiteName : Default Web Site
ApplicationPoolName : DefaultAppPool
SiteId : 1
SiteState : Stopped
SiteName : DemoWebApp111
ApplicationPoolName : DemoWebApp111
SiteId : 2
SiteState : Started
ProcessId : not found
SiteName : DemoWebApp222
ApplicationPoolName : DemoWebApp222
SiteId : 3
SiteState : Started
ProcessId : 2024
Instrumented : true
InstrumentationKey : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx123
SiteName : DemoWebApp333
ApplicationPoolName : DemoWebApp333
SiteId : 4
SiteState : Started
ProcessId : 5184
AppAlreadyInstrumented : true
在此範例中;
- 電腦識別碼 是用來唯一識別伺服器的匿名識別碼。 如果您建立支援要求,我們需要此識別碼來尋找伺服器的記錄。
- 預設網站 已在 IIS 中停止
- DemoWebApp111 已在 IIS 中啟動,但尚未收到任何要求。 此報告顯示沒有執行中的進程 (ProcessId: 找不到)。
- DemoWebApp222 正在執行且正在監視中(已檢測:true)。 根據使用者設定,檢測金鑰 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx123 已為此月臺進行比對。
- DemoWebApp333 已使用 Application Insights SDK 手動檢測。 Application Insights 代理程式偵測到 SDK,且不會監視此網站。
範例:PowerShell 模組資訊
執行 命令 Get-ApplicationInsightsMonitoringStatus -PowerShellModule
以顯示目前模組的相關資訊:
Get-ApplicationInsightsMonitoringStatus -PowerShellModule
PowerShell Module version:
0.4.0-alpha
Application Insights SDK version:
2.9.0.3872
Executing PowerShell Module Assembly:
Microsoft.ApplicationInsights.Redfield.Configurator.PowerShell, Version=2.8.14.11432, Culture=neutral, PublicKeyToken=31bf3856ad364e35
PowerShell Module Directory:
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\0.2.2\content\PowerShell
Runtime Paths:
ParentDirectory (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content
ConfigurationPath (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\applicationInsights.ikey.config
ManagedHttpModuleHelperPath (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AppInsights.IIS.ManagedHttpModuleHelper.dll
RedfieldIISModulePath (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.dll
InstrumentationEngine86Path (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation32\MicrosoftInstrumentationEngine_x86.dll
InstrumentationEngine64Path (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\MicrosoftInstrumentationEngine_x64.dll
InstrumentationEngineExtensionHost86Path (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation32\Microsoft.ApplicationInsights.ExtensionsHost_x86.dll
InstrumentationEngineExtensionHost64Path (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\Microsoft.ApplicationInsights.ExtensionsHost_x64.dll
InstrumentationEngineExtensionConfig86Path (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation32\Microsoft.InstrumentationEngine.Extensions.config
InstrumentationEngineExtensionConfig64Path (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\Microsoft.InstrumentationEngine.Extensions.config
ApplicationInsightsSdkPath (Exists: True)
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.dll
範例:執行時間狀態
您可以檢查已檢測電腦上的程式,以查看是否已載入所有 DLL。 如果監視正常運作,應該至少載入 12 個 DLL。
執行 Get-ApplicationInsightsMonitoringStatus -InspectProcess
命令:
Get-ApplicationInsightsMonitoringStatus -InspectProcess
iisreset.exe /status
Status for IIS Admin Service ( IISADMIN ) : Running
Status for Windows Process Activation Service ( WAS ) : Running
Status for Net.Msmq Listener Adapter ( NetMsmqActivator ) : Running
Status for Net.Pipe Listener Adapter ( NetPipeActivator ) : Running
Status for Net.Tcp Listener Adapter ( NetTcpActivator ) : Running
Status for World Wide Web Publishing Service ( W3SVC ) : Running
handle64.exe -accepteula -p w3wp
BF0: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.ServerTelemetryChannel.dll
C58: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.AzureAppServices.dll
C68: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.DependencyCollector.dll
C78: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.WindowsServer.dll
C98: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.Web.dll
CBC: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.PerfCounterCollector.dll
DB0: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.AI.Agent.Intercept.dll
B98: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.dll
BB4: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.Contracts.dll
BCC: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.Redfield.Lightup.dll
BE0: File (R-D) C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.dll
listdlls64.exe -accepteula w3wp
0x0000000019ac0000 0x127000 C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\MicrosoftInstrumentationEngine_x64.dll
0x00000000198b0000 0x4f000 C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\Microsoft.ApplicationInsights.ExtensionsHost_x64.dll
0x000000000c460000 0xb2000 C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\Microsoft.ApplicationInsights.Extensions.Base_x64.dll
0x000000000ad60000 0x108000 C:\Windows\TEMP\2.4.0.0.Microsoft.ApplicationInsights.Extensions.Intercept_x64.dll
參數
(無參數)
根據預設,此 Cmdlet 會報告 Web 應用程式的監視狀態。 使用此選項來檢閱您的應用程式是否已成功檢測。 您也可以檢閱哪些檢測金鑰符合您的網站。
-PowerShellModule
選擇性 。 使用此參數來報告監視所需的 DLL 版本號碼和路徑。 如果您需要識別任何 DLL 的版本,包括 Application Insights SDK,請使用此選項。
-InspectProcess
選擇性 。 使用此參數來報告 IIS 是否正在執行。 它會下載外部工具,以判斷是否需要將 DLL 載入 IIS 執行時間。
如果此程式因任何原因而失敗,您可以手動執行下列命令:
- iisreset.exe /status
- handle64.exe -p w3wp | findstr /I 「InstrumentationEngine AI. ApplicationInsights」
- listdlls64.exe w3wp | findstr /I 「InstrumentationEngine AI ApplicationInsights」
-Force
選擇性 。 僅搭配 InspectProcess 使用。 使用此參數略過在下載更多工具之前出現的使用者提示。
Set-ApplicationInsightsMonitoringConfig
設定組態檔,而不執行完整重新安裝。 重新開機 IIS,讓變更生效。
重要
此 Cmdlet 需要具有管理員許可權的 PowerShell 會話。
範例
單一檢測金鑰的範例
在此範例中,目前電腦上的所有應用程式都會指派單一檢測金鑰。
Enable-ApplicationInsightsMonitoring -InstrumentationKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
檢測金鑰組應的範例
在此範例中:
MachineFilter
使用'.*'
萬用字元比對目前電腦。AppFilter='WebAppExclude'
null
提供檢測金鑰。 未檢測指定的應用程式。AppFilter='WebAppOne'
將指定的應用程式指派為唯一的檢測金鑰。AppFilter='WebAppTwo'
將指定的應用程式指派為唯一的檢測金鑰。AppFilter
會'.*'
使用萬用字元來比對它尚未相符的 Web 應用程式,並指派預設檢測金鑰。- 新增空格以取得可讀性。
Enable-ApplicationInsightsMonitoring -InstrumentationKeyMap `
` @(@{MachineFilter='.*';AppFilter='WebAppExclude'},
` @{MachineFilter='.*';AppFilter='WebAppOne';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1'}},
` @{MachineFilter='.*';AppFilter='WebAppTwo';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2'}},
` @{MachineFilter='.*';AppFilter='.*';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxdefault'}})
參數
-InstrumentationKey
必要。 使用此參數來提供單一檢測金鑰,以供目的電腦上的所有應用程式使用。
-InstrumentationKeyMap
必要。 使用此參數來提供多個檢測金鑰,以及每個應用程式所使用的檢測金鑰組應。
您可以藉由設定 MachineFilter
來建立數部電腦的單一安裝腳本。
重要
應用程式會依規則提供的順序,比對規則。 因此,您應該先指定最特定的規則,最後指定最泛型的規則。
結構描述
@(@{MachineFilter='.*';AppFilter='.*';InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'})
- MachineFilter 是電腦或 VM 名稱的必要 C# RegEx。
- '.*' 符合所有專案
- 'ComputerName' 只會比對具有指定名稱的電腦。
- AppFilter 是電腦或 VM 名稱的必要 C# RegEx。
- '.*' 符合所有專案
- 'ApplicationName' 只會比對具有指定名稱的 IIS 應用程式。
- 必須有 InstrumentationKey ,才能監視符合上述兩個篩選準則的應用程式。
- 如果您想要定義規則以排除監視,請將此值保留為 null。
-詳細
一般參數。 使用此參數可顯示詳細的記錄。
輸出
根據預設,沒有輸出。
透過 -InstrumentationKey 設定組態檔的範例詳細資訊輸出
VERBOSE: Operation: InstallWithIkey
VERBOSE: InstrumentationKeyMap parsed:
Filters:
0)InstrumentationKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx AppFilter: .* MachineFilter: .*
VERBOSE: set config file
VERBOSE: Config File Path:
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\applicationInsights.ikey.config
透過 -InstrumentationKeyMap 設定組態檔的範例詳細資訊輸出
VERBOSE: Operation: InstallWithIkeyMap
VERBOSE: InstrumentationKeyMap parsed:
Filters:
0)InstrumentationKey: AppFilter: WebAppExclude MachineFilter: .*
1)InstrumentationKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2 AppFilter: WebAppTwo MachineFilter: .*
2)InstrumentationKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxdefault AppFilter: .* MachineFilter: .*
VERBOSE: set config file
VERBOSE: Config File Path:
C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\applicationInsights.ikey.config
Start-ApplicationInsightsMonitoringTrace
從無程式碼附加執行時間收集 ETW 事件 。 此 Cmdlet 是執行 PerfView 的替代方案。
系統會收集事件、即時列印到主控台,並儲存至 ETL 檔案。 您可以使用 PerfView 開啟輸出 ETL 檔案 ,以進行進一步調查。
此 Cmdlet 會執行,直到達到逾時持續時間(預設為 5 分鐘)或手動停止為止( Ctrl + C
)。
範例
如何收集事件
一般而言,我們會要求您收集事件來調查應用程式未檢測的原因。
無程式碼附加執行時間會在 IIS 啟動時和應用程式啟動時發出 ETW 事件。
若要收集這些事件:
- 在具有系統管理員許可權的 Cmd 主控台中,執行
iisreset /stop
以停止 IIS 和所有 Web 應用程式。 - 執行此 Cmdlet
- 在具有系統管理員許可權的 Cmd 主控台中,執行
iisreset /start
以啟動 IIS。 - 嘗試流覽至您的應用程式。
- 在應用程式完成載入之後,您可以手動停止它 (
Ctrl + C
) 或等候逾時。
要收集哪些事件
收集事件時,您有三個選項:
- 使用 參數
-CollectSdkEvents
收集從 Application Insights SDK 發出的事件。 - 使用 參數
-CollectRedfieldEvents
來收集 Application Insights 代理程式和 Redfield Runtime 所發出的事件。 診斷 IIS 和應用程式啟動時,這些記錄會很有説明。 - 使用這兩個參數來收集這兩種事件種類。
- 根據預設,如果未指定參數,則會收集這兩種事件種類。
參數
-MaxDurationInMinutes
選擇性。 使用此參數來設定此腳本應該收集事件的時間長度。 預設值為 5 分鐘。
-LogDirectory
選擇性。 使用此參數可設定 ETL 檔案的輸出目錄。 根據預設,此檔案會在 PowerShell Modules 目錄中建立。 完整路徑會顯示在腳本執行期間。
-CollectSdkEvents
選擇性。 使用此參數來收集 Application Insights SDK 事件。
-CollectRedfieldEvents
選擇性。 使用此參數從 Application Insights 代理程式和 Redfield 執行時間收集事件。
-詳細
一般參數。 使用此參數來輸出詳細記錄。
輸出
應用程式開機記錄的範例
Start-ApplicationInsightsMonitoringTrace -CollectRedfieldEvents
Starting...
Log File: C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\logs\20190627_144217_ApplicationInsights_ETW_Trace.etl
Tracing enabled, waiting for events.
Tracing will timeout in 5 minutes. Press CTRL+C to cancel.
2:42:31 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace Resolved variables to: MicrosoftAppInsights_ManagedHttpModulePath='C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.dll', MicrosoftAppInsights_ManagedHttpModuleType='Microsoft.ApplicationInsights.RedfieldIISModule.RedfieldIISModule'
2:42:31 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace Resolved variables to: MicrosoftDiagnosticServices_ManagedHttpModulePath2='', MicrosoftDiagnosticServices_ManagedHttpModuleType2=''
2:42:31 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace Environment variable 'MicrosoftDiagnosticServices_ManagedHttpModulePath2' or 'MicrosoftDiagnosticServices_ManagedHttpModuleType2' is null, skipping managed dll loading
2:42:31 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace MulticastHttpModule.constructor, success, 70 ms
2:42:31 PM EVENT: Microsoft-ApplicationInsights-RedfieldIISModule Trace Current assembly 'Microsoft.ApplicationInsights.RedfieldIISModule, Version=2.8.18.27202, Culture=neutral, PublicKeyToken=f23a46de0be5d6f3' location 'C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.dll'
2:42:31 PM EVENT: Microsoft-ApplicationInsights-RedfieldIISModule Trace Matched filter '.*'~'STATUSMONITORTE', '.*'~'DemoWithSql'
2:42:31 PM EVENT: Microsoft-ApplicationInsights-RedfieldIISModule Trace Lightup assembly calculated path: 'C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.Redfield.Lightup.dll'
2:42:31 PM EVENT: Microsoft-ApplicationInsights-FrameworkLightup Trace Loaded applicationInsights.config from assembly's resource Microsoft.ApplicationInsights.Redfield.Lightup, Version=2.8.18.27202, Culture=neutral, PublicKeyToken=f23a46de0be5d6f3/Microsoft.ApplicationInsights.Redfield.Lightup.ApplicationInsights-recommended.config
2:42:34 PM EVENT: Microsoft-ApplicationInsights-FrameworkLightup Trace Successfully attached ApplicationInsights SDK
2:42:34 PM EVENT: Microsoft-ApplicationInsights-RedfieldIISModule Trace RedfieldIISModule.LoadLightupAssemblyAndGetLightupHttpModuleClass, success, 2687 ms
2:42:34 PM EVENT: Microsoft-ApplicationInsights-RedfieldIISModule Trace RedfieldIISModule.CreateAndInitializeApplicationInsightsHttpModules(lightupHttpModuleClass), success
2:42:34 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace ManagedHttpModuleHelper, multicastHttpModule.Init() success, 3288 ms
2:42:35 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace Resolved variables to: MicrosoftAppInsights_ManagedHttpModulePath='C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.dll', MicrosoftAppInsights_ManagedHttpModuleType='Microsoft.ApplicationInsights.RedfieldIISModule.RedfieldIISModule'
2:42:35 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace Resolved variables to: MicrosoftDiagnosticServices_ManagedHttpModulePath2='', MicrosoftDiagnosticServices_ManagedHttpModuleType2=''
2:42:35 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace Environment variable 'MicrosoftDiagnosticServices_ManagedHttpModulePath2' or 'MicrosoftDiagnosticServices_ManagedHttpModuleType2' is null, skipping managed dll loading
2:42:35 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace MulticastHttpModule.constructor, success, 0 ms
2:42:35 PM EVENT: Microsoft-ApplicationInsights-RedfieldIISModule Trace RedfieldIISModule.CreateAndInitializeApplicationInsightsHttpModules(lightupHttpModuleClass), success
2:42:35 PM EVENT: Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper Trace ManagedHttpModuleHelper, multicastHttpModule.Init() success, 0 ms
Timeout Reached. Stopping...
版本附注更新列于此處。
2.0.0
- 已將 Application Insights .NET/.NET Core SDK 更新為
2.21.0-redfield
2.0.0-Beta3
- 已將 Application Insights .NET/.NET Core SDK 更新為
2.20.1-redfield
- 已啟用 SQL 查詢集合
2.0.0-Beta2
已將 Application Insights .NET/.NET Core SDK 更新為 2.18.1-redfield
2.0.0-Beta1
已新增 ASP.NET Core 自動結構功能
常見問題集
本節提供常見問題的解答。
Application Insights 代理程式是否支援 Proxy 安裝?
是。 有多種方式可以下載 Application Insights 代理程式:
- 如果您的電腦具有網際網路存取權,您可以使用參數上架至PowerShell 資源庫
-Proxy
。 - 您也可以手動下載模組,並在電腦上安裝模組,或直接使用它。
每個選項都會在詳細指示 中 說明。
Application Insights 代理程式是否支援 ASP.NET Core 應用程式?
是。 在 Application Insights Agent 2.0.0 和更新版本中,支援裝載在 IIS 中的 ASP.NET Core 應用程式。
如何?確認啟用成功嗎?
您可以使用 Get-ApplicationInsightsMonitoringStatus Cmdlet 來確認啟用成功。
使用 即時計量 快速判斷您的應用程式是否正在傳送遙測。
您也可以使用 Log Analytics 列出目前傳送遙測的所有雲端角色:
union * | summarize count() by cloud_RoleName, cloud_RoleInstance
如何?達到 Proxy 傳遞嗎?
若要達到 Proxy 傳遞,請設定電腦層級 Proxy 或應用層級 Proxy。 請參閱 DefaultProxy 。
範例 Web.config:
<system.net>
<defaultProxy>
<proxy proxyaddress="http://xx.xx.xx.xx:yyyy" bypassonlocal="true"/>
</defaultProxy>
</system.net>
疑難排解
請參閱專用 的疑難排解文章 。
測試應用程式主機與擷取服務之間的連線能力
Application Insights SDK 和代理程式會傳送遙測,以擷取作為對擷取端點的 REST 呼叫。 您可以使用來自 PowerShell 或 curl 命令的原始 REST 用戶端,測試從 Web 服務器或應用程式主機電腦到擷取服務端點的連線。 請參閱 針對 Azure 監視器 Application Insights 中遺漏的應用程式遙測進行疑難排解。
下一步
檢視您的遙測:
- 探索監視效能和使用方式的 計量。
- 搜尋事件和記錄 以診斷問題。
- 使用 Log Analytics 進行更進階的 查詢。
- 建立儀表板 。
新增更多遙測:
- 可用性概觀
- 新增 Web 用戶端遙測 ,以查看網頁程式碼的例外狀況,並啟用追蹤呼叫。
- 將 Application Insights SDK 新增至您的程式碼 ,以便插入追蹤和記錄呼叫。
使用 Application Insights 代理程式執行更多動作: