Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core ApplicationInsights dotnet核心自定义初始值设定项_Asp.net Core_.net Core_Azure Application Insights - Fatal编程技术网

Asp.net core ApplicationInsights dotnet核心自定义初始值设定项

Asp.net core ApplicationInsights dotnet核心自定义初始值设定项,asp.net-core,.net-core,azure-application-insights,Asp.net Core,.net Core,Azure Application Insights,我不知道如何为aspnetcore项目配置AI。我已经做了以下工作: services.AddSingleton<ITelemetryInitializer, AppInsightsInitializer>(); services.AddApplicationInsightsTelemetry(Configuration); 我没有applicationNights.config文件(我知道不需要它们) 问题:每个日志有4个条目(相同id)。数据是正确的。我在日志中还发现以下错误:

我不知道如何为aspnetcore项目配置AI。我已经做了以下工作:

services.AddSingleton<ITelemetryInitializer, AppInsightsInitializer>();
services.AddApplicationInsightsTelemetry(Configuration);
我没有applicationNights.config文件(我知道不需要它们)

问题:每个日志有4个条目(相同id)。数据是正确的。我在日志中还发现以下错误:

AI: Error collecting 9 of the configured performance counters. Please check the configuration.  Counter \Process(??APP_WIN32_PROC??)\% Processor Time: Failed to perform the first read for performance counter. Please make sure it exists. 
Category: Process, counter: % Processor Time, instance Counter \Memory\Available Bytes: Failed to register performance counter. 
Category: Memory, counter: Available Bytes, instance: . 
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: Failed to perform the first read for performance counter. Please make sure it exists. 
Category: ASP.NET Applications, counter: Requests/Sec, instance MyCoolv3.Api.exe Counter \.NET CLR Exceptions(??APP_CLR_PROC??)\# of Exceps Thrown / sec: Failed to perform the first read for performance counter. Please make sure it exists. 
Category: .NET CLR Exceptions, counter: # of Exceps Thrown / sec, instance Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time: Failed to perform the first read for performance counter. Please make sure it exists. 
Category: ASP.NET Applications, counter: Request Execution Time, instance MyCoolv3.Api.exe Counter \Process(??APP_WIN32_PROC??)\Private Bytes: Failed to perform the first read for performance counter. Please make sure it exists. Category: Process, counter: Private Bytes, instance Counter \Process(??APP_WIN32_PROC??)\IO Data Bytes/sec: Failed to perform the first read for performance counter. Please make sure it exists. 
Category: Process, counter: IO Data Bytes/sec, instance Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests In Application Queue: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests In Application Queue, instance MyCoolv3.Api.exe 
Counter \Processor(_Total)\% Processor Time: Failed to register performance counter. Category: Processor, counter: % Processor Time, instance: _Total.
我正在使用:

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />

不再需要了(假设,您甚至应该在这条线上收到弃用警告?)

如果您在VS2017中创建一个asp.net核心新项目,AI将已经存在于包引用中(尽管是2.0版本,而不是2.1 beta版本),并且所有连接都将在
program.cs
和其他一些文件中完成

如果您正在移植一个现有的应用程序,那么您将使用

.UseApplicationInsights()
在你的
程序中.cs
启动你的应用程序。有关更多详细信息,请参阅

我们还正在更新VS2017中的“配置应用程序洞察”工具,以便在将来的更新中正确“迁移”类似的应用程序


我不知道为什么你会得到任何事件的多个实例,除非你显式地记录它们,或者如果你可能有多个启动调用(这也不会影响任何事情)。您在哪里看到多个实例?在VS的appinsights工具中?在门户中?

相关问题:如果我想在Program.cs中的WebBuilder上使用UseApplicationInsights()时以编程方式添加遥测密钥,但这是在启动配置之前执行的(这是我从keyvault加载遥测密钥的地方)。我还考虑在WebBuilder上调用UseConfiguration(xx)并从xx检索配置,然后将其用作UseApplicationInsights的参数。。。思想?
services.AddApplicationInsightsTelemetry(Configuration);
.UseApplicationInsights()