Application Insights 遥测数据模型Application Insights telemetry data model

Azure Application Insights 将遥测从 Web 应用程序发送到 Azure 门户,以便分析应用程序的性能和使用情况。Azure Application Insights sends telemetry from your web application to the Azure portal, so that you can analyze the performance and usage of your application. 标准化遥测模型可以创建不依赖于平台和语言的监测。The telemetry model is standardized so that it is possible to create platform and language-independent monitoring.

Application Insights 收集的数据为典型的应用程序执行模式建模:Data collected by Application Insights models this typical application execution pattern:

Application Insights 应用程序模型

使用以下类型的遥测监视应用的执行情况。The following types of telemetry are used to monitor the execution of your app. Application Insights SDK 通常会从 Web 应用程序框架自动收集以下三种类型:The following three types are typically automatically collected by the Application Insights SDK from the web application framework:

  • 请求 - 生成该类型的遥测用以记录应用接收的请求。Request - Generated to log a request received by your app. 例如,Application Insights Web SDK 会自动为 Web 应用接收到的每个 HTTP 请求生成请求遥测项。For example, the Application Insights web SDK automatically generates a Request telemetry item for each HTTP request that your web app receives.

    “操作” 是处理请求的执行线程。An Operation is the threads of execution that processes a request. 还可以编写代码监视其他类型的操作,例如 Web 作业或函数中定期处理数据的“唤醒”操作。You can also write code to monitor other types of operation, such as a "wake up" in a web job or function that periodically processes data. 每个操作都有一个 ID。Each operation has an ID. 此 ID 可用于对应用处理请求时生成的所有遥测进行分组This ID that can be used to group all telemetry generated while your app is processing the request. 每个操作无论成功或失败都需要持续一段时间。Each operation either succeeds or fails, and has a duration of time.

  • 异常 - 通常表示导致操作失败的异常。Exception - Typically represents an exception that causes an operation to fail.

  • 依赖项 - 表示从应用到外部服务或存储(如 REST API 或 SQL)的调用。Dependency - Represents a call from your app to an external service or storage such as a REST API or SQL. 在 ASP.NET 中,对 SQL 的依赖项调用由 System.Data 定义。In ASP.NET, dependency calls to SQL are defined by System.Data. 对 HTTP 终结点的调用由 System.Net 定义。Calls to HTTP endpoints are defined by System.Net.

Application Insights 为自定义遥测提供了三种额外的数据类型:Application Insights provides three additional data types for custom telemetry:

  • 跟踪 - 直接使用或通过适配器使用熟悉的检测框架(如 Log4NetSystem.Diagnostics)实现诊断日志记录。Trace - used either directly, or through an adapter to implement diagnostics logging using an instrumentation framework that is familiar to you, such as Log4Net or System.Diagnostics.
  • 事件 - 通常用于捕获用户与服务的交互,以分析使用模式。Event - typically used to capture user interaction with your service, to analyze usage patterns.
  • 指标 - 用于报告定期标量度量。Metric - used to report periodic scalar measurements.

每个遥测项目均可定义上下文信息,如应用程序版本或用户会话 ID。上下文是一组强类型化字段,可解锁某些方案。Every telemetry item can define the context information like application version or user session id. Context is a set of strongly typed fields that unblocks certain scenarios. 正确初始化应用程序版本后,Application Insights 可检测应用程序行为中与重新部署相关的新模式。When application version is properly initialized, Application Insights can detect new patterns in application behavior correlated with redeployment. 会话 ID 可用于计算出现中断或问题对用户造成的影响。Session id can be used to calculate the outage or an issue impact on users. 错误跟踪或关键异常可计算某些失败依赖项的不同会话 ID 值计数,较好地反映影响。Calculating distinct count of session id values for certain failed dependency, error trace or critical exception gives a good understanding of an impact.

Application Insights 遥测模型定义了将遥测与它所属的操作进行关联的方式。Application Insights telemetry model defines a way to correlate telemetry to the operation of which it’s a part. 例如,请求可以发出 SQL 数据库调用并记录诊断信息。For example, a request can make a SQL Database calls and recorded diagnostics info. 可为那些要绑回请求遥测的遥测项设置关联上下文。You can set the correlation context for those telemetry items that tie it back to the request telemetry.

架构改进Schema improvements

Application Insights 数据模型采用简单基本的结构,不过,它能够非常有效地为应用程序遥测建模。Application Insights data model is a simple and basic yet powerful way to model your application telemetry. 我们将努力保持该模型的精简结构,以便支持基本方案,并让用户根据高级用途扩展架构。We strive to keep the model simple and slim to support essential scenarios and allow to extend the schema for advanced use.

若要报告数据模型或架构问题以及建议,请使用 GitHub 存储库To report data model or schema problems and suggestions use our GitHub repository.

后续步骤Next steps