为本地服务器部署 Azure Monitor Application Insights 代理Deploy Azure Monitor Application Insights Agent for on-premises servers
重要
对于 Application Insights 代理的本地和非 Azure 云部署,建议使用本指南。This guidance is recommended for On-Premises and non-Azure cloud deployments of Application Insights Agent. 下面是建议用于 Azure 虚拟机和虚拟机规模集部署的方法。Here's the recommended approach for Azure virtual machine and virtual machine scale set deployments.
Application Insights 代理(以前称为状态监视器 V2)是发布到 PowerShell 库的 PowerShell 模块。Application Insights Agent (formerly named Status Monitor V2) is a PowerShell module published to the PowerShell Gallery. 它将替换状态监视器。It replaces Status Monitor. 遥测数据将发送到 Azure 门户,你可以在其中监视应用。Telemetry is sent to the Azure portal, where you can monitor your app.
备注
目前,该模块仅支持使用 IIS 托管的 .NET Web 应用的无代码检测。The module only currently supports codeless instrumentation of .NET web apps hosted with IIS. 使用 SDK 检测 ASP.NET Core、Java 和 Node.js 应用程序。Use an SDK to instrument ASP.NET Core, Java, and Node.js applications.
PowerShell 库PowerShell Gallery
Application Insights 代理位于此处: https://www.powershellgallery.com/packages/Az.ApplicationMonitor 。Application Insights Agent is located here: https://www.powershellgallery.com/packages/Az.ApplicationMonitor.
InstructionsInstructions
- 请参阅入门说明,从简明的代码示例开始学习。See the getting started instructions to get a start with concise code samples.
- 请参阅详细说明,以深入了解如何开始使用。See the detailed instructions for a deep dive on how to get started.
PowerShell API 参考PowerShell API reference
- Disable-ApplicationInsightsMonitoringDisable-ApplicationInsightsMonitoring
- Disable-InstrumentationEngineDisable-InstrumentationEngine
- Enable-ApplicationInsightsMonitoringEnable-ApplicationInsightsMonitoring
- Enable-InstrumentationEngineEnable-InstrumentationEngine
- Get-ApplicationInsightsMonitoringConfigGet-ApplicationInsightsMonitoringConfig
- Get-ApplicationInsightsMonitoringStatusGet-ApplicationInsightsMonitoringStatus
- Set-ApplicationInsightsMonitoringConfigSet-ApplicationInsightsMonitoringConfig
- Start-ApplicationInsightsMonitoringTraceStart-ApplicationInsightsMonitoringTrace
故障排除Troubleshooting
常见问题解答FAQ
Application Insights 代理是否支持代理安装?Does Application Insights Agent support proxy installations?
是。Yes. 可以通过多种方式下载 Application Insights 代理。There are multiple ways to download Application Insights Agent. 如果计算机可以访问 Internet,则可以使用
-Proxy
参数登录到 PowerShell 库。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.状态监视器 v2 是否支持 ASP.NET Core 应用程序?Does Status Monitor v2 support ASP.NET Core applications?
不。No. 有关启用对 ASP.NET Core 应用程序的监视的说明,请参阅适用于 ASP.NET Core 应用程序的 Application Insights。For instructions to enable monitoring of ASP.NET Core applications, see Application Insights for ASP.NET Core applications. 无需为 ASP.NET Core 应用程序安装 StatusMonitor。There's no need to install StatusMonitor for an ASP.NET Core application. 即使 ASP.NET Core 应用程序托管在 IIS 中,也是如此。This is true even if ASP.NET Core application is hosted in IIS.
如何验证启用是否成功?How do I verify that the enablement succeeded?
Get-ApplicationInsightsMonitoringStatus cmdlet 可用于验证启用是否成功。The Get-ApplicationInsightsMonitoringStatus cmdlet can be used to verify that enablement succeeded.
我们建议你使用实时指标来快速确定应用是否正在发送遥测数据。We recommend you use Live Metrics to quickly determine if your app is sending telemetry.
还可以使用 Log Analytics 列出当前正在发送遥测数据的所有云角色:You can also use Log Analytics to list all the cloud roles currently sending telemetry:
union * | summarize count() by cloud_RoleName, cloud_RoleInstance
后续步骤Next steps
查看遥测:View your telemetry:
- 浏览指标,以便监视性能和使用情况。Explore metrics to monitor performance and usage.
- 搜索事件和日志以诊断问题。Search events and logs to diagnose problems.
- 使用分析,以便进行更高级的查询。Use Analytics for more advanced queries.
- 创建仪表板。Create dashboards.
添加更多遥测:Add more telemetry:
- 创建 Web 测试,以确保站点保持活动状态。Create web tests to make sure your site stays live.
- 添加 Web 客户端遥测,以查看网页代码中的异常并启用跟踪调用。Add web client telemetry to see exceptions from web page code and to enable trace calls.
- 将 Application Insights SDK 添加到代码,以便插入跟踪和日志调用。Add the Application Insights SDK to your code so you can insert trace and log calls.