什么是 Application Insights?What is Application Insights?
Application Insights 是 Azure Monitor 的一项功能,是面向开发人员和 DevOps 专业人员的可扩展应用程序性能管理 (APM) 服务。Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals. 使用它可以监视实时应用程序。Use it to monitor your live applications. 它将自动检测性能异常,并且包含了强大的分析工具来帮助诊断问题,了解用户在应用中实际执行了哪些操作。It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. 它旨在帮助持续提高性能与可用性。It's designed to help you continuously improve performance and usability. 它适用于本地云、混合云或任何公有云中托管的各种平台(包括 .NET、Node.js、Java 和 Python)上的应用。It works for apps on a wide variety of platforms including .NET, Node.js, Java, and Python hosted on-premises, hybrid, or any public cloud. 它与 DevOps 进程集成,并且具有与不同开发工具的连接点。It integrates with your DevOps process, and has connection points to a variety of development tools. 可以通过与 Visual Studio App Center 集成来监视和分析移动应用的遥测数据。It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center.
Application Insights 的工作原理是什么?How does Application Insights work?
你可以在应用程序中安装小型检测包 (SDK),或者使用 Application Insights 代理启用 Application Insights(如果受支持)。You install a small instrumentation package (SDK) in your application or enable Application Insights using the Application Insights Agent when supported. 检测技术会监视应用,并使用我们称为“检测密钥”的唯一 GUID 将遥测数据定向到 Azure Application Insights 资源。The instrumentation monitors your app and directs the telemetry data to an Azure Application Insights Resource using a unique GUID that we refer to as an Instrumentation Key.
不仅可以检测 Web 服务应用程序,还可以检测所有后台组件以及 Web 页面中的 JavaScript。You can instrument not only the web service application, but also any background components, and the JavaScript in the web pages themselves. 应用程序及其组件可以在任何地方运行 - 不必在 Azure 中托管。The application and its components can run anywhere - it doesn't have to be hosted in Azure.
此外,还可以从主机环境(如性能计数器、Azure 诊断或 Docker 日志)中拉取遥测。In addition, you can pull in telemetry from the host environments such as performance counters, Azure diagnostics, or Docker logs. 还可以对定期向 Web 服务发送综合请求的 Web 测试进行设置。You can also set up web tests that periodically send synthetic requests to your web service.
所有这些遥测流都将集成到 Azure Monitor 中。All these telemetry streams are integrated into Azure Monitor. 在 Azure 门户中,可以对原始数据应用强大的分析和搜索工具。In the Azure portal, you can apply powerful analytic and search tools to the raw data.
什么是开销?What's the overhead?
应用性能受到的影响小。The impact on your app's performance is small. 跟踪调用是非阻塞式的,以批量方式进行并在单独的线程中发送。Tracking calls are non-blocking, and are batched and sent in a separate thread.
Application Insights 监视器的工作原理是什么?What does Application Insights monitor?
Application Insights 主要面向开发团队,旨在帮助用户了解应用的运行性能和使用方式。Application Insights is aimed at the development team, to help you understand how your app is performing and how it's being used. 监视:It monitors:
- 请求率、响应时间和失败率 - 了解最受欢迎的页面、时段以及用户的位置。Request rates, response times, and failure rates - Find out which pages are most popular, at what times of day, and where your users are. 查看哪些页面效果最好。See which pages perform best. 当有较多请求时,如果响应时间长且失败率高,则可能存在资源问题。If your response times and failure rates go high when there are more requests, then perhaps you have a resourcing problem.
- 依赖项速率、响应时间和失败率 - 了解外部服务是否正拖慢速度。Dependency rates, response times, and failure rates - Find out whether external services are slowing you down.
- 异常 - 分析聚合的统计信息,或选择特定实例并钻取堆栈跟踪和相关请求。Exceptions - Analyze the aggregated statistics, or pick specific instances and drill into the stack trace and related requests. 报告服务器和浏览器异常。Both server and browser exceptions are reported.
- 页面查看次数和负载性能 - 由用户的浏览器报告。Page views and load performance - reported by your users' browsers.
- AJAX 调用(从网页) - 速率、响应时间和失败率。AJAX calls from web pages - rates, response times, and failure rates.
- 用户和会话计数。User and session counts.
- Windows 或 Linux 服务器计算机中的 性能计数器,例如 CPU、内存和网络使用情况。Performance counters from your Windows or Linux server machines, such as CPU, memory, and network usage.
- Docker 或 Azure 中的 主机诊断。Host diagnostics from Docker or Azure.
- 应用中的 诊断跟踪日志- 可以将跟踪事件与请求相关联。Diagnostic trace logs from your app - so that you can correlate trace events with requests.
- 在客户端或服务器代码中自行编写的 自定义事件和指标,用于跟踪业务事件(例如销售的商品或赢得的游戏)。Custom events and metrics that you write yourself in the client or server code, to track business events such as items sold or games won.
在哪里可以查看我的遥测数据?Where do I see my telemetry?
可通过许多方式浏览数据。There are plenty of ways to explore your data. 请查看以下文章:Check out these articles:
智能检测和手动警报Smart detection and manual alerts 设置自动警报,使其适应应用的正常遥测模式并在出现异常情况时触发。Set up automatic alerts that adapt to your app's normal patterns of telemetry and trigger when there's something outside the usual pattern. 还可以在自定义或标准指标的特定级别上设置警报。You can also set alerts on particular levels of custom or standard metrics. |
![]() |
应用程序映射Application map 探索应用的组件,包含关键指标和警报。Explore the components of your app, with key metrics and alerts. |
![]() |
探查器Profiler 检查抽样请求的执行配置文件。Inspect the execution profiles of sampled requests. |
![]() |
使用情况分析Usage analysis 分析用户细分和保留情况。Analyze user segmentation and retention. |
![]() |
实例数据的诊断搜索Diagnostic search for instance data 搜索和筛选事件,例如请求、异常、依赖项调用、日志跟踪和页面视图。Search and filter events such as requests, exceptions, dependency calls, log traces, and page views. |
![]() |
聚合数据的指标资源管理器Metrics Explorer for aggregated data 浏览、筛选和细分聚合的数据,例如请求率、故障率和异常率;响应时间、页面加载时间。Explore, filter, and segment aggregated data such as rates of requests, failures, and exceptions; response times, page load times. |
![]() |
仪表板Dashboards 混合使用来自多个资源的数据并与他人共享。Mash up data from multiple resources and share with others. 对于多组件应用程序和在团队聊天室中连续显示很有用。Great for multi-component applications, and for continuous display in the team room. |
![]() |
实时指标流Live Metrics Stream 部署新的生成时,观看这些准实时性能指示器,确保一切按预期工作。When you deploy a new build, watch these near-real-time performance indicators to make sure everything works as expected. |
![]() |
分析Analytics 使用此功能强大的查询语言,回答有关应用的性能和使用情况的疑难问题。Answer tough questions about your app's performance and usage by using this powerful query language. |
![]() |
Visual StudioVisual Studio 查看代码中的性能数据。See performance data in the code. 从堆栈跟踪转到代码。Go to code from stack traces. |
![]() |
快照调试器Snapshot debugger 使用参数值调试从实时操作采样的快照。Debug snapshots sampled from live operations, with parameter values. |
![]() |
Power BIPower BI 将使用指标与其他商业智能集成。Integrate usage metrics with other business intelligence. |
![]() |
REST APIREST API 编写代码以对指标和原始数据运行查询。Write code to run queries over your metrics and raw data. |
![]() |
连续导出Continuous export 原始数据到达后,立即将其批量导出到存储。Bulk export of raw data to storage as soon as it arrives. |
![]() |
如何使用 Application Insights?How do I use Application Insights?
监视Monitor
在应用中安装 Application Insights,设置可用性 Web 测试,然后:Install Application Insights in your app, set up availability web tests, and:
- 为团队聊天室签出默认应用程序仪表板,以便监视负载、响应能力和依赖项性能、页面加载和 AJAX 调用。Check out the default application dashboard for your team room to keep an eye on load, responsiveness, and the performance of your dependencies, page loads, and AJAX calls.
- 发现最慢和多数情况下失败的请求。Discover which are the slowest and most failing requests.
- 在部署新版本时查看实时流,快速掌握任何降级情况。Watch Live Stream when you deploy a new release, to know immediately about any degradation.
检测、诊断Detect, Diagnose
当收到警报,或发现问题时:When you receive an alert or discover a problem:
- 评估受到影响的的用户的数量。Assess how many users are affected.
- 将失败与异常、依赖项调用和跟踪关联起来。Correlate failures with exceptions, dependency calls, and traces.
- 检查探查器、快照、堆栈转储和跟踪日志。Examine profiler, snapshots, stack dumps, and trace logs.
生成、衡量、学习Build, Measure, Learn
测量有效性(针对部署的每个新功能)。Measure the effectiveness of each new feature that you deploy.
- 规划以衡量客户使用新的 UX 或业务功能的方式。Plan to measure how customers use new UX or business features.
- 将自定义遥测写入代码。Write custom telemetry into your code.
- 使下一个开发周期基于遥测的硬性证据。Base the next development cycle on hard evidence from your telemetry.
入门Get started
Application Insights 是 Azure 中托管的众多服务之一,遥测会发送到此处进行分析和展示。Application Insights is one of the many services hosted within Azure, and telemetry is sent there for analysis and presentation. 因此在执行任何其他操作之前,需要订阅 Azure。So before you do anything else, you'll need a subscription to Azure. 可免费注册该订阅,如果选择 Application Insights 的基本pricing plan(定价计划),不会产生费用,但如果应用的使用量大幅增加,会产生费用。It's free to sign up, and if you choose the basic pricing plan of Application Insights, there's no charge until your application has grown to have substantial usage. 如果组织已有订阅,则组织可向其中添加 Microsoft 帐户。If your organization already has a subscription, they could add your Microsoft account to it.
可通过多种方法开始使用。There are several ways to get started. 可从最适合方法开始。Begin with whichever works best for you. 可在以后添加其他方法。You can add the others later.
- 运行时:检测服务器上的 Web 应用。At run time: instrument your web app on the server. 非常适合已部署的应用程序。Ideal for applications already deployed. 避免任何代码更新。Avoids any update to the code.
- 在 Azure Web 应用中托管的 ASP.NET 或 ASP.NET Core 应用程序ASP.NET or ASP.NET Core applications hosted on Azure Web Apps
- 在 Azure VM 或 Azure 虚拟机规模集的 IIS 中托管的 ASP.NET 应用程序ASP.NET applications hosted in IIS on Azure VM or Azure virtual machine scale set
- 在 VM 的 IIS 中托管的 ASP.NET 应用程序ASP.NET applications hosted in IIS on-premises VM
- 开发时:将 Application Insights 添加到代码。At development time: add Application Insights to your code. 可以自定义遥测数据收集和发送其他遥测数据。Allows you to customize telemetry collection and send additional telemetry.
- 针对页面视图、AJAX 和其他客户端遥测 检测网页 。Instrument your web pages for page view, AJAX, and other client-side telemetry.
- 通过与 Visual Studio App Center 集成 分析移动应用使用情况 。Analyze mobile app usage by integrating with Visual Studio App Center.
- 可用性测试 - 从我们的服务器定期对网站执行 ping 操作。Availability tests - ping your website regularly from our servers.
后续步骤Next steps
在运行时开始使用:Get started at runtime with:
- Azure VM 和 Azure 虚拟机规模集的托管 IIS 应用Azure VM and Azure virtual machine scale set IIS-hosted apps
- IIS 服务器IIS server
- Azure Web 应用Azure Web Apps
在开发时开始使用:Get started at development time with:
支持和反馈Support and feedback
- 问题:Questions and Issues:
- 用户建议:Your suggestions:
- 博客:Blog:
- Application Insights blog(Application Insights 博客)Application Insights blog