管理 Application Insights 的使用情况和成本Manage usage and costs for Application Insights


本文介绍如何了解和控制 Application Insights 的成本。This article describes how to understand and control your costs for Application Insights. 相关文章监视使用情况及预估成本介绍了如何针对不同的定价模型查看多个 Azure 监视功能的使用情况及预估成本。A related article, Monitoring usage and estimated costs describes how to view usage and estimated costs across multiple Azure monitoring features for different pricing models.

无论 Web 应用程序是托管在 Azure 中还是本地,Application Insights 都会提供所需的功能,便于你监视其可用性、性能和使用情况。Application Insights is designed to get everything you need to monitor the availability, performance, and usage of your web applications, whether they're hosted on Azure or on-premises. Application Insights 支持 .NET、Java 和 Node.js 等常用语言和框架,并与 Azure DevOps、Jira 和 PagerDuty 等 DevOps 流程和工具相集成。Application Insights supports popular languages and frameworks, such as .NET, Java, and Node.js, and integrates with DevOps processes and tools like Azure DevOps, Jira, and PagerDuty. 请务必了解能够确定应用程序监视成本的因素。It's important to understand what determines the costs of monitoring your applications. 本文介绍能够产生应用程序监视成本的因素,以及如何主动监视成本。In this article, we review what drives your application monitoring costs and how you can proactively monitor and control them.

如果对 Application Insights 定价工作原理存在疑问,欢迎在我们的 Microsoft Q&A 问题页面提出问题。If you have questions about how pricing works for Application Insights, you can post a question in our Microsoft Q&A question page.

定价模型Pricing model

Azure Application Insights 采用基于引入的数据量(还可以选择用于更长的数据保留期)的即用即付模型。The pricing for Azure Application Insights is a Pay-As-You-Go model based on data volume ingested and optionally for longer data retention. 每个 Application Insights 资源作为独立服务计费,并在 Azure 订阅的帐单中产生相应费用。Each Application Insights resource is charged as a separate service and contributes to the bill for your Azure subscription. 数据量的衡量标准是 Application Insights 从用户应用程序收到的未压缩 JSON 数据包的大小。Data volume is measured as the size of the uncompressed JSON data package that's received by Application Insights from your application. 使用实时指标流时,不会根据数据量收费。There is no data volume charge for using the Live Metrics Stream.

多步骤 Web 测试会额外收费。Multi-step web tests incur an additional charge. 多步骤 Web 测试是指执行一系列操作的 Web 测试。Multi-step web tests are web tests that perform a sequence of actions. 单页“ping 测试”不单独计费。There's no separate charge for ping tests of a single page. 进行 ping 测试和多步测试时发送的遥测数据与应用发送的其他遥测数据计费方式相同。Telemetry from ping tests and multi-step tests is charged the same as other telemetry from your app.

用于对自定义指标维度启用警报的 Application Insights 选项也可能会产生额外的费用,因为这可能会导致创建其他预聚合指标。The Application Insights option to Enable alerting on custom metric dimensions can also generate in additional costs because this can result in the creation of additional pre-aggregation metrics. 详细了解 Application Insights 中基于日志的预聚合指标,以及有关 Azure Monitor 自定义指标的定价Learn more about log-based and pre-aggregated metrics in Application Insights and about pricing for Azure Monitor custom metrics.

基于工作区的 Application InsightsWorkspace-based Application Insights

对于将数据发送到 Log Analytics 工作区的 Application Insights 资源(称为基于工作区的 Application Insights 资源),数据引入和保留的计费由 Application Insights 数据所在的工作区完成。For Application Insights resources which send their data to a Log Analytics workspace, called workspace-based Application Insights resources, the billing for data ingestion and retention is done by the workspace where the Application Insights data is located. 这样,客户除了能够使用“即用即付”定价模型之外,还能使用 Log Analytics 定价模型的所有选项,其中包括“预留产能”。This enables customers to leverage all options of the Log Analytics pricing model that includes Capacity Reservations in addition to Pay-As-You-Go. Log Analytics 还提供了更多数据保留选项,包括按数据类型保留Log Analytics also has more options for data retention, including retention by data type. 工作区中的 Application Insights 数据类型具有 90 天的保留期,无需支付费用。Application Insights data types in the workspace receive 90 days of retention without charges. 使用 Web 测试以及启用自定义指标维度警报时,仍通过 Application Insights 来报告。Usage of web tests and enabling alerting on custom metric dimensions is still reported through Application Insights. 了解如何使用使用情况和估计成本Log Analytics 查询跟踪 Log Analytics 中的数据引入和保留成本。Learn how to track data ingestion and retention costs in Log Analytics using the Usage and estimated costs and Log Analytics queries.

估算应用程序的管理成本Estimating the costs to manage your application

如果尚未使用 Application Insights,可以使用 Azure Monitor 定价计算器来估算使用 Application Insights 的成本。If you're not yet using Application Insights, you can use the Azure Monitor pricing calculator to estimate the cost of using Application Insights. 首先在搜索框中输入“Azure Monitor”,然后单击生成的 Azure Monitor 磁贴。Start by entering "Azure Monitor" in the Search box, and clicking on the resulting Azure Monitor tile. 将页面向下滚动到“Azure Monitor”,然后从“类型”下拉列表中选择“Application Insights”。Scroll down the page to Azure Monitor, and select Application Insights from the Type dropdown. 可以在这里输入每月要收集的数据的 GB 数,因此问题是 Application Insights 在监视应用程序时会收集多少数据量。Here you can enter the number of GB of data you expect to collect per month, so the question is how much data will Application Insights collect monitoring your application.

可以通过两种方法解决这个问题:使用 ASP.NET SDK 中提供的默认监视和自适应采样;或根据其他类似客户遇到的情况估算可能的数据引入量。There are two approaches to address this: use of default monitoring and adaptive sampling, which is available in the ASP.NET SDK, or estimate your likely data ingestion based on what other similar customers have seen.

在使用采样时收集数据Data collection when using sampling

使用 ASP.NET SDK 的自适应采样,系统会自动调整数据量,将数据量保持在默认 Application Insights 监视功能的最大指定流量速率范围内。With the ASP.NET SDK's adaptive sampling, the data volume is adjusted automatically to keep within a specified maximum rate of traffic for default Application Insights monitoring. 如果应用程序产生的遥测数据很少(例如在调试时或由于使用量较小所致),那么,只要数据量低于配置的每秒事件数级别,采样处理器就不会丢弃项。If the application produces a low amount of telemetry, such as when debugging or due to low usage, items won't be dropped by the sampling processor as long as volume is below the configured events per second level. 对于大数据量应用程序,默认阈值为每秒 5 个事件,自适应采样会将每日事件的数量限制为 432,000。For a high volume application, with the default threshold of five events per second, adaptive sampling will limit the number of daily events to 432,000. 使用典型的平均事件大小 1 KB,这相当于托管应用程序的每个节点每月(按平均 31 天计算)可引入 13.4 GB 的遥测数据(因为采样是在每个节点本地完成的。)Using a typical average event size of 1 KB, this corresponds to 13.4 GB of telemetry per 31-day month per node hosting your application (since the sampling is done local to each node.)

对于不支持自适应采样的 SDK,可以使用引入采样(Application Insights 收到数据时根据要保留的数据百分比采样),或使用 ASP.NET、ASP.NET Core 和 Java 网站的固定速率采样来减少从 Web 服务器和 Web 浏览器发送的流量For SDKs that don't support adaptive sampling, you can employ ingestion sampling, which samples when the data is received by Application Insights based on a percentage of data to retain, or fixed-rate sampling for ASP.NET, ASP.NET Core, and Java websites to reduce the traffic sent from your web server and web browsers

参考类似客户收集的信息Learn from what similar customers collect

在 Application Insights 的 Azure 监视定价计算器中,如果启用“根据应用程序活动估算数据量”功能,可以提供有关应用程序的输入(如果以后会收集客户端遥测数据,请提供每月请求数和页面查看次数),然后,计算器会告知类似由应用程序收集的中间值和第 90 个百分位的数据量。In the Azure Monitoring Pricing calculator for Application Insights, if you enable the "Estimate data volume based on application activity" functionality, you can provide inputs about your application (requests per month and page views per month, in case you will collect client-side telemetry), and then the calculator will tell you the median and 90th percentile amount of data collected by similar applications. 这些应用程序涉及各种 Application Insights 配置(例如,某些应用程序具有默认采样、有些没有采样等),因此你仍然拥有控制权,可以使用采样将引入的数据量减少到远低于中间值级别。These applications span the range of Application Insights configuration (e.g some have default sampling, some have no sampling etc.), so you still have the control to reduce the volume of data you ingest far below the median level using sampling. 但这只是了解其他类似客户看到的情况的一个起点。But this is a starting point to understand what other, similar customers are seeing.

了解自己的使用情况和估算成本Understand your usage and estimate costs

通过 Application Insights 可以根据最近的使用模式轻松估算成本。Application Insights makes it easy to understand what your costs are likely to be based on recent usage patterns. 若要开始使用,请在 Azure 门户中,转到 Application Insights 资源的“使用情况和估算成本”页:To get started, in the Azure portal, for the Application Insights resource, go to the Usage and estimated costs page:


A.A. 查看当月数据量。Review your data volume for the month. 这包括接收和保留的所有数据(在通过服务器和客户端应用以及可用性测试进行采样后)。This includes all the data that's received and retained (after any sampling) from your server and client apps, and from availability tests.
B.B. 多步骤 Web 测试单独收费。A separate charge is made for Multi-step web tests. (这不包括简单可用性测试,它已包括在数据量费用中。)(This doesn't include simple availability tests, which are included in the data volume charge.)
C.C. 查看上个月的数据量趋势。View data volume trends for the past month.
D.D. 启用数据引入采样Enable data ingestion sampling. E.E. 设置每日数据量上限。Set the daily data volume cap.

(请注意,本文的屏幕截图中显示的所有价格仅用作示例。(Note that all prices displayed in screenshots in this article are for example purposes only. 有关在你所在区域中以相应的货币计价的当前价格,请参阅 Application Insights 定价For current prices in your currency and region, see Application Insights pricing.)

若要更深入地调查 Application Insights 使用情况,请打开“指标”页,添加名为“数据点容量”的指标,然后选择“应用拆分”选项以按“遥测项类型”拆分数据。To investigate your Application Insights usage more deeply, open the Metrics page, add the metric named "Data point volume", and then select the Apply splitting option to split the data by "Telemetry item type".

使用数据量指标Using data volume metrics

为了详细了解数据量,请针对 Application Insights 资源选择“指标”,添加一个新图表。To learn more about your data volumes, selecting Metrics for your Application Insights resource, add a new chart. 对于图表指标,在“基于日志的指标”下,选择“数据点容量” 。For the chart metric, under Log-based metrics, select Data point volume. 单击“应用拆分”,然后按“Telemetryitem 类型”选择组。Click Apply splitting, and select group by Telemetryitem type.


用于了解数据量详细信息的查询Queries to understand data volume details

可通过两种方法调查 Application Insights 的数据量。There are two approaches to investigating data volumes for Application Insights. 第一种方法是使用 systemEvents 表中的聚合信息,第二种方法是使用每个引入事件中都提供的 _BilledSize 属性。The first uses aggregated information in the systemEvents table, and the second uses the _BilledSize property, which is available on each ingested event. systemEvents 不会提供 workspace-based-application-insights 的数据大小信息。systemEvents will not have data size information for workspace-based-application-insights.

使用聚合数据量信息Using aggregated data volume information

例如,可以使用 systemEvents 表,通过以下查询查看最近 24 小时内引入的数据量:For instance, you can use the systemEvents table to see the data volume ingested in the last 24 hours with the query:

| where timestamp >= ago(24h)
| where type == "Billing"
| extend BillingTelemetryType = tostring(dimensions["BillingTelemetryType"])
| extend BillingTelemetrySizeInBytes = todouble(measurements["BillingTelemetrySize"])
| summarize sum(BillingTelemetrySizeInBytes)

或者,若要按数据类型查看最近 30 天的数据量图表(以字节为单位),可以使用以下查询:Or to see a chart of data volume (in bytes) by data type for the last 30 days, you can use:

| where timestamp >= startofday(ago(30d))
| where type == "Billing"
| extend BillingTelemetryType = tostring(dimensions["BillingTelemetryType"])
| extend BillingTelemetrySizeInBytes = todouble(measurements["BillingTelemetrySize"])
| summarize sum(BillingTelemetrySizeInBytes) by BillingTelemetryType, bin(timestamp, 1d) | render barchart  

请注意,在 Azure 日志警报中,可以使用此查询对数据量设置警报。Note that this query can be used in an Azure Log Alert to set up alerting on data volumes.

若要详细了解遥测数据的更改情况,可以使用以下查询按类型获取事件计数:To learn more about your telemetry data changes, we can get the count of events by type using the query:

| where timestamp >= startofday(ago(30d))
| where type == "Billing"
| extend BillingTelemetryType = tostring(dimensions["BillingTelemetryType"])
| summarize count() by BillingTelemetryType, bin(timestamp, 1d)
| render barchart  

针对每个事件信息使用数据大小Using data size per event information

若要详细了解数据量的来源,可以使用每个引入事件中已有的 _BilledSize 属性。To learn more details about the source of your data volumes, you can use the _BilledSize property that is present on each ingested event.

例如,若要查看在过去 30 天内哪些操作生成的数据量最多,可以将所有依赖项事件的 _BilledSize 求和:For example, to look at which operations generate the most data volume in the last 30 days, we can sum _BilledSize for all dependency events:

| where timestamp >= startofday(ago(30d))
| summarize sum(_BilledSize) by operation_Name
| render barchart  

基于工作区的 Application Insights 资源的数据量Data volume for workspace-based Application Insights resources

若要查看过去一周内工作区中所有基于工作区的 Application Insights 资源的数据量趋势,请转到 Log Analytics 工作区并运行以下查询:To look at the data volume trends for all of the workspace-based Application Insights resources in a workspace for the last week, go to the Log Analytics workspace and run the query:

union (AppAvailabilityResults),
| where TimeGenerated >= startofday(ago(7d)) and TimeGenerated < startofday(now())
| summarize sum(_BilledSize) by _ResourceId, bin(TimeGenerated, 1d)
| render areachart

若要按类型查询基于工作区的特定 Application Insights 资源的数据量趋势,请在 Log Analytics 工作区中使用以下查询:To query the data volume trends by type for a specific workspace-based Application Insights resource, in the Log Analytics workspace use:

union (AppAvailabilityResults),
| where TimeGenerated >= startofday(ago(7d)) and TimeGenerated < startofday(now())
| where _ResourceId contains "<myAppInsightsResourceName>"
| summarize sum(_BilledSize) by Type, bin(TimeGenerated, 1d)
| render areachart

管理数据量Managing your data volume

可以使用以下方法管理发送的数据量:The volume of data you send can be managed using the following techniques:

  • 采样:可以使用采样减少从服务器和客户端应用发送的遥测量,同时最大程度减小指标失真。Sampling: You can use sampling to reduce the amount of telemetry that's sent from your server and client apps, with minimal distortion of metrics. 采样是你可用来调整发送数据量的主要工具。Sampling is the primary tool you can use to tune the amount of data you send. 了解有关采样功能的详细信息。Learn more about sampling features.

  • 限制 AJAX 调用:可以限制每个页面视图中可报告的 AJAX 调用数,也可以关闭 AJAX 报表。Limit Ajax calls: You can limit the number of Ajax calls that can be reported in every page view, or switch off Ajax reporting.

  • 禁用不需要的模块:编辑 ApplicationInsights.config 关闭不需要的集合模块。Disable unneeded modules: Edit ApplicationInsights.config to turn off collection modules that you don't need. 例如,用户可能认为不再需要性能计数器或依赖项数据。For example, you might decide that performance counters or dependency data are inessential.

  • 预先聚合指标:如果将对 TrackMetric 的调用放在应用中,则可通过使用重载降低流量,这种重载接受对一批度量值的平均偏差和标准偏差的计算结果。Pre-aggregate metrics: If you put calls to TrackMetric in your app, you can reduce traffic by using the overload that accepts your calculation of the average and standard deviation of a batch of measurements. 也可使用预先聚合包Or, you can use a pre-aggregating package.

  • 每日上限:在 Azure 门户中创建 Application Insights 资源时,每日上限设置为 100 GB/天。Daily cap: When you create an Application Insights resource in the Azure portal, the daily cap is set to 100 GB/day. 在 Visual Studio 中创建 Application Insights 资源时,默认值很小(只有 32.3 MB/天)。When you create an Application Insights resource in Visual Studio, the default is small (only 32.3 MB/day). 设置每日上限默认值,以便进行测试。The daily cap default is set to facilitate testing. 可预期用户在将应用部署到生产环境之前,会提高每日上限。It's intended that the user will raise the daily cap before deploying the app into production.

    除非为高流量应用程序请求了更高的最大值,否则最大上限是 1000 GB/天。The maximum cap is 1,000 GB/day unless you request a higher maximum for a high-traffic application.

    有关每日上限的提醒电子邮件将发送到作为 Application Insights 资源的以下角色的成员的帐户:“ServiceAdmin”、”AccountAdmin”、”CoAdmin”、”Owner”。Warning emails about the daily cap are sent to account that are members of these roles for your Application Insights resource: "ServiceAdmin", "AccountAdmin", "CoAdmin", "Owner".

    设置每日上限时,务必小心。Use care when you set the daily cap. 你的目标应该是“永远不会达到每日上限”。Your intent should be to never hit the daily cap. 如果达到每日上限,会丢失当天剩余时间的数据,无法监视应用程序。If you hit the daily cap, you lose data for the remainder of the day, and you can't monitor your application. 若要更改每日上限,请使用“每日容量上限”选项。To change the daily cap, use the Daily volume cap option. 可在“使用情况和预估成本”窗格中访问此选项(本文后面会详述)。You can access this option in the Usage and estimated costs pane (this is described in more detail later in the article).

    对于具有无法用于 Application Insights 的额度的某些订阅类型,我们已去除此限制。We've removed the restriction on some subscription types that have credit that couldn't be used for Application Insights. 以前,如果订阅有支出限制,“每日上限”对话框将提供如何去除此限制,并使每日上限提高到超过 32.3 MB/天的说明。Previously, if the subscription has a spending limit, the daily cap dialog has instructions to remove the spending limit and enable the daily cap to be raised beyond 32.3 MB/day.

  • 限制:此项将数据速率限制为每秒 32,000 个事件,取每个检测密钥 1 分钟的平均值。Throttling: Throttling limits the data rate to 32,000 events per second, averaged over 1 minute per instrumentation key. 每分钟会评估一次应用发送的数据量。The volume of data that your app sends is assessed every minute. 如果超出一分钟内的平均每秒速率,服务器将拒绝某些请求。If it exceeds the per-second rate averaged over the minute, the server refuses some requests. SDK 将缓冲数据,然后尝试重新发送该数据。The SDK buffers the data and then tries to resend it. 它会在几分钟内出现传播高峰。It spreads out a surge over several minutes. 如果应用连续以超出限制的速率发送数据,一些数据会被丢弃。If your app consistently sends data at more than the throttling rate, some data will be dropped. (ASP.NET、Java 和 JavaScript SDK 会尝试以这种方式重新发送;其他 SDK 可能会只是丢弃超出限制的数据。)如果发生超出限制的情况,会显示一个通知,警告发生了这种情况。(The ASP.NET, Java, and JavaScript SDKs try to resend data this way; other SDKs might simply drop throttled data.) If throttling occurs, a notification warning alerts you that this has occurred.

管理每日最大数据量Manage your maximum daily data volume

可以使用每日容量上限,限制所收集的数据。You can use the daily volume cap to limit the data collected. 但是,如果达到上限,会丢失当天剩余时间从应用程序发送的所有遥测数据。However, if the cap is met, a loss of all telemetry sent from your application for the remainder of the day occurs. 不建议使应用程序达到每日上限。It is not advisable to have your application hit the daily cap. 达到每日上限后,无法跟踪应用程序的运行状况和性能。You can't track the health and performance of your application after it reaches the daily cap.

不使用每日容量上限,而是使用采样,将数据量调整到所需级别。Instead of using the daily volume cap, use sampling to tune the data volume to the level you want. 然后,仅在应用程序意外开始发送远高于预期的遥测量时,才使用每日上限作为“最后的手段”。Then, use the daily cap only as a "last resort" in case your application unexpectedly begins to send much higher volumes of telemetry.

确定要定义的每日数据限制Identify what daily data limit to define

查看 Application Insights 使用情况和估算成本,了解数据引入趋势以及要定义的每日数据量上限。Review Application Insights Usage and estimated costs to understand the data ingestion trend and what is the daily volume cap to define. 应慎重考虑此上限,因为在达到限制后,将无法监视资源。It should be considered with care, since you won't be able to monitor your resources after the limit is reached.

设置每日上限Set the Daily Cap

若要更改每日上限,请在“使用情况和估算成本”页面中的“Application Insights”资源的“配置”部分,选择“每日上限” 。To change the daily cap, in the Configure section of your Application Insights resource, in the Usage and estimated costs page, select Daily Cap.


若要通过 Azure 资源管理器更改每日上限,需要更改 dailyQuota 属性。To change the daily cap via Azure Resource Manager, the property to change is the dailyQuota. 通过 Azure 资源管理器,还可以设置 dailyQuotaResetTime 以及每日上限的 warningThresholdVia Azure Resource Manager you can also set the dailyQuotaResetTime and the daily cap's warningThreshold.

创建针对每日上限的警报Create alerts for the Daily Cap

当引入的数据量达到警告级别或每日上限级别时,“Application Insights 每日上限”会在 Azure 活动日志中创建一个事件。The Application Insights Daily Cap creates an event in the Azure activity log when the ingested data volumes reaches the warning level or the daily cap level. 可以基于这些活动日志事件创建警报You can create an alert based on these activity log events. 这些事件的信号名称如下:The signal names for these events are:

  • 已达到 Application Insights 组件的每日上限警告阈值Application Insights component daily cap warning threshold reached

  • 已达到 Application Insights 组件的每日上限Application Insights component daily cap reached


采样是一种方法,可降低向应用发送遥测的速率,同时仍可在诊断搜索过程中查找相关事件。sampling is a method of reducing the rate at which telemetry is sent to your app, while retaining the ability to find related events during diagnostic searches. 此外,还可保留正确的事件计数。You also retain correct event counts.

采样是降低费用同时又不超出每月配额的有效方式。Sampling is an effective way to reduce charges and stay within your monthly quota. 采样算法会保留遥测的相关项,这样,当使用“搜索”时便可查找与特定异常相关的请求。The sampling algorithm retains related items of telemetry so, for example, when you use Search, you can find the request related to a particular exception. 该算法还保留正确计数,使用户可在指标资源管理器中看到请求率、异常率和其他计数的正确值。The algorithm also retains correct counts so you see the correct values in Metric Explorer for request rates, exception rates, and other counts.

有数种形式的采样。There are several forms of sampling.

  • 自适应采样是用于 ASP.NET SDK 的默认设置。Adaptive sampling is the default for the ASP.NET SDK. 自适应采样可自动调整为应用发送的遥测量。Adaptive sampling automatically adjusts to the volume of telemetry that your app sends. 它会在 Web 应用的 SDK 中自动运行,以便减少网络上的遥测流量。It operates automatically in the SDK in your web app so that telemetry traffic on the network is reduced.
  • 引入采样 是一种替代方法,会在应用的遥测进入 Application Insights 服务时运行。Ingestion sampling is an alternative that operates at the point where telemetry from your app enters the Application Insights service. 引入采样不会影响从应用发送的遥测量,但会减少服务保留的量。Ingestion sampling doesn't affect the volume of telemetry sent from your app, but it reduces the volume that's retained by the service. 可以使用引入采样来降低来自浏览器和其他 SDK 的遥测所使用的配额。You can use ingestion sampling to reduce the quota that's used up by telemetry from browsers and other SDKs.

若要设置引入采样,请转到“定价”窗格:To set ingestion sampling, go to the Pricing pane:



“数据采样”窗格仅控制引入采样的值。The Data sampling pane controls only the value of ingestion sampling. 它不反映 Application Insights SDK 在应用中应用的采样速率。It doesn't reflect the sampling rate that's applied by the Application Insights SDK in your app. 如果传入的遥测已在 SDK 处进行了采样,则引入采样不适用。If the incoming telemetry has already been sampled in the SDK, ingestion sampling isn't applied.

若要查找实际采样率(无论是否已应用),请使用分析查询To discover the actual sampling rate, no matter where it's been applied, use an Analytics query. 该查询如下所示:The query looks like this:

requests | where timestamp > ago(1d)
| summarize 100/avg(itemCount) by bin(timestamp, 1h)
| render areachart

在每个保留的记录中,itemCount 指示它表示的原始记录数。In each retained record, itemCount indicates the number of original records that it represents. 它等于 1 +(即以前已放弃的记录数)。It's equal to 1 + the number of previous discarded records.

更改数据保留期Change the data retention period

Application Insights 资源的默认保留期为 90 天。The default retention for Application Insights resources is 90 days. 可以为每个 Application Insights 资源选择不同的保留期。Different retention periods can be selected for each Application Insights resource. 可以从以下保留期中选择:30 天、60 天、90 天、120 天、180 天、270 天、365 天、550 天或 730 天。The full set of available retention periods is 30, 60, 90, 120, 180, 270, 365, 550 or 730 days. 详细了解针对更长数据保留期的定价。Learn more about pricing for longer data retention.

若要更改保留期,请从 Application Insights 资源转到“使用情况和估算成本”页,然后选择“数据保留”选项 :To change the retention, from your Application Insights resource, go to the Usage and Estimated Costs page and select the Data Retention option:


如果保留期天数减少,则在删除最旧的数据之前,会有几天的宽限期。When the retention is lowered, there is a several day grace period before the oldest data is removed.

还可以通过 PowerShell 使用 retentionInDays 参数以编程方式设置保留期。The retention can also be set programatically using PowerShell using the retentionInDays parameter. 如果将数据保留期设置为 30 天,可以使用 immediatePurgeDataOn30Days 参数触发立即清除以前的数据的操作,这对于合规性相关的场景可能很有用。If you set the data retention to 30 days, you can trigger an immediate purge of older data using the immediatePurgeDataOn30Days parameter, which may be useful for compliance-related scenarios. 此清除功能仅通过 Azure 资源管理器公开,切记请谨慎使用。This purge functionality is only exposed via Azure Resource Manager and should be used with extreme care. 可以使用 Azure 资源管理器设置 dailyQuotaResetTime 参数,配置数据量上限的每日重置时间。The daily reset time for the data volume cap can be configured using Azure Resource Manager to set the dailyQuotaResetTime parameter.

使用 Application Insights 时的数据传输费用Data transfer charges using Application Insights

向 Application Insights 发送数据可能会产生数据带宽费用。Sending data to Application Insights might incur data bandwidth charges. Azure 带宽定价页中所述,位于两个区域内的 Azure 服务之间的数据传输按出站数据传输以正常费率计费。As described in the Azure Bandwidth pricing page, data transfer between Azure services located in two regions charged as outbound data transfer at the normal rate. 入站数据传输是免费的。Inbound data transfer is free. 但是,相比 Application Insights 日志数据引入费,此传输费很低(只占几个百分比)。However, this charge is very small (few %) compared to the costs for Application Insights log data ingestion. 因此,控制 Log Analytics 的成本需要将重心放在引入的数据量上,并且我们在此处提供了有助于了解相关内容的指南。Consequently controlling costs for Log Analytics needs to focus on your ingested data volume, and we have guidance to help understand that here.

限制摘要Limits summary

每个应用程序(即每个检测密钥)的指标和事件数都有一些限制。There are some limits on the number of metrics and events per application, that is, per instrumentation key. 限制取决于选择的定价计划Limits depend on the pricing plan that you choose.

ResourceResource 默认限制Default limit 注意Note
每日的总数据量Total data per day 100 GB100 GB 可以通过设置一个上限来减少数据。You can reduce data by setting a cap. 如果需要更多数据,可以在门户中最多将上限提高到 1,000 GB。If you need more data, you can increase the limit in the portal, up to 1,000 GB. 容量大于 1,000 GB,将发送电子邮件发送到AIDataCap@microsoft.com。For capacities greater than 1,000 GB, send email to AIDataCap@microsoft.com.
限制Throttling 32,000 事件/秒32,000 events/second 限制按分钟计量。The limit is measured over a minute.
数据保留Data retention 90 天90 days 此资源适用于搜索分析指标资源管理器This resource is for Search, Analytics.
90 天90 days 此资源提供了每个步骤的详细结果。This resource provides detailed results of each step.
最大事件大小Maximum event size 64,00064,000
属性和指标名称长度Property and metric name length 150150 请参阅类型架构See type schemas.
属性值字符串长度Property value string length 8,1928,192 请参阅类型架构See type schemas.
跟踪和异常消息长度Trace and exception message length 32,76832,768 请参阅类型架构See type schemas.

有关详细信息,请参阅关于 Application Insights 中的定价和配额For more information, see About pricing and quotas in Application Insights.

禁用每日上限电子邮件Disable daily cap e-mails

若要禁用每日容量上限电子邮件,请在“使用情况和预估成本”窗格中 Application Insights 资源的“配置”部分下,选择“每日上限” 。To disable the daily volume cap e-mails, under the Configure section of your Application Insights resource, in the Usage and estimated costs pane, select Daily Cap. 有一些在达到上限时以及达到可调整的警告等级时发送电子邮件的设置。There are settings to send e-mail when the cap is reached, as well as when an adjustable warning level has been reached. 如果要禁用与每日容量上限相关的所有电子邮件,请取消选中这两个框。If you wish to disable all daily cap volume-related emails, uncheck both boxes.

旧式企业(按节点)定价层Legacy Enterprise (Per Node) pricing tier

对于 Azure Application Insights 的早期采用者而言,仍有两种可能存在的定价层:基本计划和企业计划。For early adopters of Azure Application Insights, there are still two possible pricing tiers: Basic and Enterprise. “基本”定价层如上所述,它是默认层。The Basic pricing tier is the same as described above and is the default tier. 其中包括所有的“企业”层功能,不另外收费。It includes all Enterprise tier features, at no additional cost. “基本”层主要针对所引入的数据量计费。The Basic tier bills primarily on the volume of data that's ingested.


这些旧的定价层已经过重命名。These legacy pricing tiers have been renamed. “企业”定价层现在称为“按节点”层,而“基本”定价层现在称为“按 GB”层 。The Enterprise pricing tier is now called Per Node and the Basic pricing tier is now called Per GB. 下文和 Azure 门户中将使用这些新名称。These new names are used below and in the Azure portal.

“按节点”(以前称为“企业”)层按节点收费,并且每个节点都会收到每日数据限额。The Per Node (formerly Enterprise) tier has a per-node charge, and each node receives a daily data allowance. 在“按节点”定价层中,你需要为引入的数据中超出规定限额的数据付费。In the Per Node pricing tier, you are charged for data ingested above the included allowance. 如果你使用的是 Operations Management Suite,应选择“按节点”层。If you are using Operations Management Suite, you should choose the Per Node tier.

有关在你所在区域中以适合你的货币计价的当前价格,请参阅 Application Insights 定价For current prices in your currency and region, see Application Insights pricing.


在 2018 年 4 月,我们引入了 Azure 监视的新定价模型。In April 2018, we introduced a new pricing model for Azure monitoring. 此模型在监视服务的完整组合中采用简单的“即用即付”模型。This model adopts a simple "pay-as-you-go" model across the complete portfolio of monitoring services. 深入了解新的定价模型、如何根据使用模式评估移到此模型的影响以及如何选择加入该新模型Learn more about the new pricing model, how to assess the impact of moving to this model based on your usage patterns, and how to opt into the new model

“按节点”层和 Operations Management Suite 订阅权利Per Node tier and Operations Management Suite subscription entitlements

按照最近的公告,客户如果购买了 Operations Management Suite E1 和 E2,则能够免费获取 Application Insights 的“按节点”作为附加组件。Customers who purchase Operations Management Suite E1 and E2 can get Application Insights Per Node as an additional component at no additional cost as previously announced. 具体而言,Operations Management Suite E1 和 E2 的每个单位都包含对 Application Insights“按节点”层的 1 个节点的权利。Specifically, each unit of Operations Management Suite E1 and E2 includes an entitlement to one node of the Application Insights Per Node tier. 每个 Application Insights 节点包含每天最多 200 MB 的引入数据(独立于 Log Analytics 数据引入),并且数据会保留 90 天,无额外费用。Each Application Insights node includes up to 200 MB of data ingested per day (separate from Log Analytics data ingestion), with 90-day data retention at no additional cost. 本文后面会详述该层。The tier is described in more detailed later in the article.

由于此层仅适用于使用 Operations Management Suite 订阅的客户,因此,没有 Operations Management Suite 订阅的客户不会看到用于选择此层的选项。Because this tier is applicable only to customers with an Operations Management Suite subscription, customers who don't have an Operations Management Suite subscription don't see an option to select this tier.


若要确保获取此权利,Application Insights 资源必须位于“按节点”定价层中。To ensure that you get this entitlement, your Application Insights resources must be in the Per Node pricing tier. 此权利仅以节点的形式应用。This entitlement applies only as nodes. “按 GB”层中的 Application Insights 资源不会实现任何权益。Application Insights resources in the Per GB tier don't realize any benefit. 此权利不会出现在“使用情况和预估成本”窗格中显示的预估成本中。This entitlement isn't visible in the estimated costs shown in the Usage and estimated cost pane. 此外,如果在 2018 年 4 月将订阅移到了新的 Azure 监视定价模型,则只有“按 GB”层可用。Also, if you move a subscription to the new Azure monitoring pricing model in April 2018, the Per GB tier is the only tier available. 如果具有 Operations Management Suite 订阅,不建议将订阅移到新的 Azure 监视定价模型。Moving a subscription to the new Azure monitoring pricing model isn't advisable if you have an Operations Management Suite subscription.

“按节点”层的工作原理How the Per Node tier works

  • 你需要针对为“按节点”层中的任何应用发送遥测数据的每个节点付费。You pay for each node that sends telemetry for any apps in the Per Node tier.
    • 节点 是托管应用的物理/虚拟服务器计算机或平台即服务角色实例。A node is a physical or virtual server machine or a platform-as-a-service role instance that hosts your app.
    • 开发计算机、客户端浏览器和移动设备不计为节点。Development machines, client browsers, and mobile devices do not count as nodes.
    • 如果应用有多个组件(例如 Web 服务和后端辅助角色)发送遥测数据,则会对组件分开计数。If your app has several components that send telemetry, such as a web service and a back-end worker, the components are counted separately.
    • 定价未考虑实时指标流数据。Live Metrics Stream data isn't counted for pricing purposes. 在订阅中,将按节点而非应用计费。In a subscription, your charges are per node, not per app. 如果有 5 个节点在为 12 个应用发送遥测数据,则按 5 个节点计费。If you have five nodes that send telemetry for 12 apps, the charge is for five nodes.
  • 虽然是按月计费,但对于从应用发送遥测数据的节点来说,实际上是按小时计费。Although charges are quoted per month, you're charged only for any hour in which a node sends telemetry from an app. 小时费率为月费除以 744(每月的小时数,每月按 31 天算)。The hourly charge is the quoted monthly charge divided by 744 (the number of hours in a 31-day month).
  • 每天为每个检测到的节点分配的数据量为 200 MB(时间粒度为小时)。A data volume allocation of 200 MB per day is given for each node that's detected (with hourly granularity). 分配的数据如果未使用,不会从当天转到第二天。Unused data allocation isn't carried over from one day to the next.
    • 如果选择“按节点”定价层,则每个订阅都会收到基于向该订阅中的 Application Insights 资源发送遥测数据的节点数的每日数据限额。If you choose the Per Node pricing tier, each subscription gets a daily allowance of data based on the number of nodes that send telemetry to the Application Insights resources in that subscription. 因此,如果全天有 5 个节点在发送数据,则该订阅中的所有 Application Insights 资源可以共用 1 GB 的数据限额。So, if you have five nodes that send data all day, you'll have a pooled allowance of 1 GB applied to all Application Insights resources in that subscription. 无所谓某些节点是否比其他节点发送更多数据,因为包含的数据在所有节点之间共享。It doesn't matter if certain nodes send more data than other nodes because the included data is shared across all nodes. 如果 Application Insights 资源在特定的某一天收到的数据量超出了为该订阅分配的每日数据限额,则会对超额数据按 GB 计费。If on a given day, the Application Insights resources receive more data than is included in the daily data allocation for this subscription, the per-GB overage data charges apply.
    • 每日数据限额的计算方式为所有节点在一天中发送遥测数据的小时数(使用 UTC 计时方式)除以 24 再乘以 200 MB。The daily data allowance is calculated as the number of hours in the day (using UTC) that each node sends telemetry divided by 24 multiplied by 200 MB. 因此,如果有 4 个节点一天 24 小时中有 15 个小时在发送遥测,则当天包含的数据为 ((4 × 15) / 24) × 200 MB = 500 MB。So, if you have four nodes that send telemetry during 15 of the 24 hours in the day, the included data for that day would be ((4 × 15) / 24) × 200 MB = 500 MB. 超额数据的价格为 2.30 美元/GB,如果当天发送了 1 GB 的数据,则收费 1.15 美元。At the price of 2.30 USD per GB for data overage, the charge would be 1.15 USD if the nodes send 1 GB of data that day.
    • “按节点”层的每日限额不与已为其选择“按 GB”层的应用程序共享。The Per Node tier daily allowance isn't shared with applications for which you have chosen the Per GB tier. 未使用的限额不能从当天转到第二天。Unused allowance isn't carried over from day-to-day.

演示如何确定不同节点计数的示例Examples of how to determine distinct node count

方案Scenario 每日节点计数总数Total daily node count
1 个应用程序使用 3 个 Azure 应用服务实例和 1 个虚拟服务器1 application using 3 Azure App Service instances and 1 virtual server 44
3 个应用程序正运行在 2 个 VM 上,这些应用程序的 Application Insights 资源属于同一订阅,并且位于“按节点”层中3 applications running on 2 VMs; the Application Insights resources for these applications are in the same subscription and in the Per Node tier 22
4 个应用程序的 Applications Insights 资源属于同一订阅;每个应用程序在 16 小时的非高峰时段内运行 2 个实例,在 8 小时的高峰时段内运行 4 个实例4 applications whose Applications Insights resources are in the same subscription; each application running 2 instances during 16 off-peak hours, and 4 instances during 8 peak hours 13.3313.33
云服务有 1 个辅助角色和 1 个 Web 角色,每个角色运行 2 个实例Cloud services with 1 Worker Role and 1 Web Role, each running 2 instances 44
5 节点 Azure Service Fabric 群集运行 50 个微服务;每个微服务运行 3 个实例A 5-node Azure Service Fabric cluster running 50 microservices; each microservice running 3 instances 55
  • 若要进行精确的节点计数,必须了解应用程序在使用哪个 Application Insights SDK。The precise node counting depends on which Application Insights SDK your application is using.
    • 在 SDK 2.2 及更高版本中,Application Insights Core SDKWeb SDK 都会将每个应用程序主机作为节点进行报告。In SDK versions 2.2 and later, both the Application Insights Core SDK and the Web SDK report each application host as a node. 例如,会报告物理服务器和 VM 主机的计算机名称,而对于云服务,则报告实例名称。Examples are the computer name for physical server and VM hosts or the instance name for cloud services. 唯一的例外是应用程序仅使用 .NET Core 和 Application Insights Core SDK。The only exception is an application that uses only the .NET Core and the Application Insights Core SDK. 在这种情况下,所有主机只会报告一个节点,因为主机名不可用。In that case, only one node is reported for all hosts because the host name isn't available.
    • 就早期版本的 SDK 来说,Web SDK 的行为与新版 SDK 并无二致,而 Core SDK 则只会报告一个节点,不管应用程序主机的数目是多少。For earlier versions of the SDK, the Web SDK behaves like the newer SDK versions, but the Core SDK reports only one node, regardless of the number of application hosts.
    • 如果应用程序通过 SDK 将 roleInstance 设置为自定义值,则会默认使用该值确定节点计数。If your application uses the SDK to set roleInstance to a custom value, by default, that same value is used to determine node count.
    • 如果对从客户端计算机或移动设备运行的应用使用新版 SDK,则节点计数可能会返回一个较大数目(因为客户端计算机或移动设备的数目很大)。If you're using a new SDK version with an app that runs from client machines or mobile devices, the node count might return a number that's large (because of the large number of client machines or mobile devices).


可以使用 Azure 资源管理编写脚本来设置定价层。You can write a script to set the pricing tier by using Azure Resource Management. 了解操作方法Learn how.

后续步骤Next steps