Deploy Azure Monitor Application Insights Agent for on-premises servers
Application Insights Agent (formerly named Status Monitor V2) is a PowerShell module published to the PowerShell Gallery. It replaces Status Monitor. Telemetry is sent to the Azure portal, where you can monitor your app.
For a complete list of supported autoinstrumentation scenarios, see Supported environments, languages, and resource providers.
Note
The module currently supports codeless instrumentation of ASP.NET and ASP.NET Core web apps hosted with IIS. Use an SDK to instrument Java and Node.js applications.
Note
Client-side monitoring is enabled by default for ASP.NET Core apps. If you want to disable client-side monitoring, define an environment variable in the server with the following information:
- Name:
APPINSIGHTS_JAVASCRIPT_ENABLED
- Value:
false
Application Insights Agent is located in the PowerShell Gallery.
- To get started with concise code samples, see the Getting started tab.
- For a deep dive on how to get started, see the Detailed instructions tab.
- For PowerShell API reference, see the API reference tab.
- For release note updates, see the Release notes tab.
This tab describes the following cmdlets, which are members of the Az.ApplicationMonitor PowerShell module:
- Enable-InstrumentationEngine
- Enable-ApplicationInsightsMonitoring
- Disable-InstrumentationEngine
- Disable-ApplicationInsightsMonitoring
- Get-ApplicationInsightsMonitoringConfig
- Get-ApplicationInsightsMonitoringStatus
- Set-ApplicationInsightsMonitoringConfig
- Start-ApplicationInsightsMonitoringTrace
Note
- To get started, you need a connection string. For more information, see Create a resource.
- This cmdlet requires that you review and accept our license and privacy statement.
Note
On March 31, 2025, support for instrumentation key ingestion will end. Instrumentation key ingestion will continue to work, but we'll no longer provide updates or support for the feature. Transition to connection strings to take advantage of new capabilities.
Important
This cmdlet requires a PowerShell session with Admin permissions and an elevated execution policy. For more information, see Run PowerShell as administrator with an elevated execution policy.
- This cmdlet requires that you review and accept our license and privacy statement.
- The instrumentation engine adds additional overhead and is off by default.
Enables the instrumentation engine by setting some registry keys. Restart IIS for the changes to take effect.
The instrumentation engine can supplement data collected by the .NET SDKs. It collects events and messages that describe the execution of a managed process. These events and messages include dependency result codes, HTTP verbs, and SQL command text.
Enable the instrumentation engine if:
- You already enabled monitoring with the
Enable
cmdlet but didn't enable the instrumentation engine. - You manually instrumented your app with the .NET SDKs and want to collect extra telemetry.
Enable-InstrumentationEngine
Optional. Use this switch to accept the license and privacy statement in headless installations.
Common parameter. Use this switch to output detailed logs.
Configuring IIS Environment for instrumentation engine...
Configuring registry for instrumentation engine...
Enables codeless attach monitoring of IIS apps on a target computer.
This cmdlet modifies the IIS applicationHost.config and sets some registry keys. It creates an applicationinsights.ikey.config file, which defines the instrumentation key used by each app. IIS loads the RedfieldModule on startup, which injects the Application Insights SDK into applications as the applications start. Restart IIS for your changes to take effect.
After you enable monitoring, we recommend that you use Live Metrics to quickly check if your app is sending us telemetry.
In this example, all apps on the current computer are assigned a single connection string.
Enable-ApplicationInsightsMonitoring -ConnectionString 'InstrumentationKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;IngestionEndpoint=https://xxxx.applicationinsights.azure.cn/'
In this example, all apps on the current computer are assigned a single instrumentation key.
Enable-ApplicationInsightsMonitoring -InstrumentationKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
In this example:
MachineFilter
matches the current computer by using the'.*'
wildcard.AppFilter='WebAppExclude'
provides anull
instrumentation key. The specified app isn't instrumented.AppFilter='WebAppOne'
assigns the specified app a unique instrumentation key.AppFilter='WebAppTwo'
assigns the specified app a unique instrumentation key.AppFilter
uses the'.*'
wildcard to match any web apps it doesn't already match and assigns a default instrumentation key.- Spaces are added for readability.
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'}})
Note
The naming of AppFilter in this context can be confusing, AppFilter
sets the application name regex filter (HostingEnvironment.SiteName in the case of .NET on IIS). VirtualPathFilter
sets the virtual path regex filter (HostingEnvironment.ApplicationVirtualPath in the case of .NET on IIS). To instrument a single app you would use the VirtualPathFilter as follows: Enable-ApplicationInsightsMonitoring -InstrumentationKeyMap @(@{VirtualPathFilter="^/MyAppName$"; InstrumentationSettings=@{InstrumentationKey='<your ikey>'}})
Required. Use this parameter to supply a single connection string for use by all apps on the target computer.
Required. Use this parameter to supply a single instrumentation key for use by all apps on the target computer.
Required. Use this parameter to supply multiple instrumentation keys and a mapping of the instrumentation keys used by each app.
You can create a single installation script for several computers by setting MachineFilter
.
Important
Apps matches against rules in the order that the rules are provided. So you should specify the most specific rules first and the most generic rules last.
@(@{MachineFilter='.*';AppFilter='.*';InstrumentationSettings=@{InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}})
- MachineFilter is a required C# regex of the computer or VM name.
- '.*' matches all
- 'ComputerName' matches only computers with the exact name specified.
- AppFilter is a required C# regex of the IIS Site Name. You can get a list of sites on your server by running the command get-iissite.
- '.*' matches all
- 'SiteName' matches only the IIS Site with the exact name specified.
- InstrumentationKey is required to enable monitoring of apps that match the preceding two filters.
- Leave this value null if you want to define rules to exclude monitoring.
Optional. Use this switch to enable the instrumentation engine to collect events and messages about what's happening during the execution of a managed process. These events and messages include dependency result codes, HTTP verbs, and SQL command text.
The instrumentation engine adds overhead and is off by default.
Optional. Use this switch to accept the license and privacy statement in headless installations.
When you have a cluster of web servers, you might be using a shared configuration. The HttpModule can't be injected into this shared configuration. This script fails with the message that extra installation steps are required. Use this switch to ignore this check and continue installing prerequisites. For more information, see known conflict-with-iis-shared-configuration
Common parameter. Use this switch to display detailed logs.
Common parameter. Use this switch to test and validate your input parameters without actually enabling monitoring.
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
Disables the instrumentation engine by removing some registry keys. Restart IIS for the changes to take effect.
Disable-InstrumentationEngine
Common parameter. Use this switch to output detailed logs.
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...
Disables monitoring on the target computer. This cmdlet removes edits to the IIS applicationHost.config and remove registry keys.
Disable-ApplicationInsightsMonitoring
Common parameter. Use this switch to display detailed logs.
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
Gets the config file and prints the values to the console.
Get-ApplicationInsightsMonitoringConfig
No parameters required.
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: .*
This cmdlet provides troubleshooting information about Application Insights Agent. Use this cmdlet to investigate the monitoring status, version of the PowerShell Module, and to inspect the running process. This cmdlet reports version information and information about key files required for monitoring.
Run the command Get-ApplicationInsightsMonitoringStatus
to display the monitoring status of web sites.
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
In this example;
Machine Identifier is an anonymous ID used to uniquely identify your server. If you create a support request, we need this ID to find logs for your server.
Default Web Site is Stopped in IIS
DemoWebApp111 has been started in IIS, but hasn't received any requests. This report shows that there's no running process (ProcessId: not found).
DemoWebApp222 is running and is being monitored (Instrumented: true). Based on the user configuration, Instrumentation Key xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx123 was matched for this site.
DemoWebApp333 has been manually instrumented using the Application Insights SDK. Application Insights Agent detected the SDK and doesn't monitor this site.
The presence of
AppAlreadyInstrumented : true
signifies that the Application Insights agent identified a conflicting dll loaded in the web application, assumed that the web app is manually instrumented, and the agent has backed-off and isn't instrumenting this process.Instrumented : true
indicates that the Application Insights agent successfully instrumented the web app running in the specified w3wp.exe process.
Run the command Get-ApplicationInsightsMonitoringStatus -PowerShellModule
to display information about the current module:
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
You can inspect the process on the instrumented computer to see if all DLLs are loaded. If monitoring is working, at least 12 DLLs should be loaded.
Run the command 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
By default, this cmdlet reports the monitoring status of web applications. Use this option to review if your application was successfully instrumented. You can also review which Instrumentation Key was matched to your site.
Optional. Use this switch to report the version numbers and paths of DLLs required for monitoring. Use this option if you need to identify the version of any DLL, including the Application Insights SDK.
Optional. Use this switch to report whether IIS is running. It downloads external tools to determine if the necessary DLLs are loaded into the IIS runtime.
If this process fails for any reason, you can run these commands manually:
- iisreset.exe /status
- handle64.exe -p w3wp | findstr /I "InstrumentationEngine AI. ApplicationInsights"
- listdlls64.exe w3wp | findstr /I "InstrumentationEngine AI ApplicationInsights"
Optional. Used only with InspectProcess. Use this switch to skip the user prompt that appears before more tools are downloaded.
Sets the config file without doing a full reinstallation. Restart IIS for your changes to take effect.
Important
This cmdlet requires a PowerShell session with Admin permissions.
In this example, all apps on the current computer are assigned a single instrumentation key.
Enable-ApplicationInsightsMonitoring -InstrumentationKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
In this example:
MachineFilter
matches the current computer by using the'.*'
wildcard.AppFilter='WebAppExclude'
provides anull
instrumentation key. The specified app isn't instrumented.AppFilter='WebAppOne'
assigns the specified app a unique instrumentation key.AppFilter='WebAppTwo'
assigns the specified app a unique instrumentation key.AppFilter
uses the'.*'
wildcard to match web apps it doesn't already match and assigns a default instrumentation key.- Spaces are added for readability.
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'}})
Required. Use this parameter to supply a single instrumentation key for use by all apps on the target computer.
Required. Use this parameter to supply multiple instrumentation keys and a mapping of the instrumentation keys used by each app.
You can create a single installation script for several computers by setting MachineFilter
.
Important
Apps matches against rules in the order that the rules are provided. So you should specify the most specific rules first and the most generic rules last.
@(@{MachineFilter='.*';AppFilter='.*';InstrumentationKey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'})
- MachineFilter is a required C# regex of the computer or VM name.
- '.*' matches all
- 'ComputerName' matches only computers with the specified name.
- AppFilter is a required C# regex of the computer or VM name.
- '.*' matches all
- 'ApplicationName' matches only IIS apps with the specified name.
- InstrumentationKey is required to enable monitoring of the apps that match the preceding two filters.
- Leave this value null if you want to define rules to exclude monitoring.
Common parameter. Use this switch to display detailed logs.
By default, no output.
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
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
Collects ETW Events from the codeless attach runtime. This cmdlet is an alternative to running PerfView.
Events are collected, printed to the console in real-time, and saved to an ETL file. You can open the output ETL file with PerfView for further investigation.
This cmdlet runs until it reaches the timeout duration (default 5 minutes) or is stopped manually (Ctrl + C
).
Normally we would ask that you collect events to investigate why your application isn't being instrumented.
The codeless attach runtime emits ETW events when IIS starts up and when your application starts up.
To collect these events:
- In a cmd console with admin privileges, execute
iisreset /stop
to stop IIS and all web apps. - Execute this cmdlet
- In a cmd console with admin privileges, execute
iisreset /start
to start IIS. - Try to browse to your app.
- After your app finishes loading, you can manually stop it (
Ctrl + C
) or wait for the timeout.
You have three options when collecting events:
- Use the switch
-CollectSdkEvents
to collect events emitted from the Application Insights SDK. - Use the switch
-CollectRedfieldEvents
to collect events emitted by Application Insights Agent and the Redfield Runtime. These logs are helpful when diagnosing IIS and application startup. - Use both switches to collect both event types.
- By default, if no switch is specified both event types are collected.
Optional. Use this parameter to set how long this script should collect events. Default is 5 minutes.
Optional. Use this switch to set the output directory of the ETL file. By default, this file is created in the PowerShell Modules directory. The full path is displayed during script execution.
Optional. Use this switch to collect Application Insights SDK events.
Optional. Use this switch to collect events from Application Insights Agent and the Redfield runtime.
Common parameter. Use this switch to output detailed logs.
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...
This section provides answers to common questions.
Yes. There are multiple ways to download Application Insights Agent:
- If your computer has internet access, you can onboard to the PowerShell Gallery by using
-Proxy
parameters. - You can also manually download the module and either install it on your computer or use it directly.
Each of these options is described in the detailed instructions.
Yes. In Application Insights Agent 2.0.0 and later, ASP.NET Core applications hosted in IIS are supported.
You can use the Get-ApplicationInsightsMonitoringStatus cmdlet to verify that enablement succeeded.
Use Live Metrics to quickly determine if your app is sending telemetry.
You can also use Log Analytics to list all the cloud roles currently sending telemetry:
union * | summarize count() by cloud_RoleName, cloud_RoleInstance
To achieve proxy passthrough, configure a machine-level proxy or an application-level proxy. See DefaultProxy.
Example Web.config:
<system.net>
<defaultProxy>
<proxy proxyaddress="http://xx.xx.xx.xx:yyyy" bypassonlocal="true"/>
</defaultProxy>
</system.net>
See the dedicated troubleshooting article.
Application Insights SDKs and agents send telemetry to get ingested as REST calls to our ingestion endpoints. You can test connectivity from your web server or application host machine to the ingestion service endpoints by using raw REST clients from PowerShell or curl commands. See Troubleshoot missing application telemetry in Azure Monitor Application Insights.
View your telemetry:
- Explore metrics to monitor performance and usage.
- Search events and logs to diagnose problems.
- Use Log Analytics for more advanced queries.
- Create dashboards.
Add more telemetry:
- Availability overview
- Add web client telemetry to see exceptions from webpage code and to enable trace calls.
- Add the Application Insights SDK to your code so that you can insert trace and log calls.
Do more with Application Insights Agent:
- Troubleshoot Application Insights Agent.