繁体   English   中英

.NET应用程序见解| 自定义指标未显示在portal.azure.com中的指标下

[英]Application insight .NET | Custom metrics don't show up in portal.azure.com under metrics

我具有“按需付费”模型运行的应用程序见解。 标准性能指标显示在门户中。 自定义指标不会显示在“指标”部分中。

我的环境。 运行纯TCP套接字的自定义.NET核心控制台应用程序。 (无ASP.NET CORE)使用

<PackageReference Include="Microsoft.ApplicationInsights" Version="2.7.2" />

遥测类是使用默认构造函数构造的(并且没有XML配置文件)

自定义指标的创建方式如下

Telemetry.Client.GetMetric("number of clients").TrackValue(600.0);

问题:自定义指标未显示,我想念或做错了什么? 天蓝色门户中的“度量标准”部分在寻找自定义度量标准的地方不正确吗?

更新

该示例代码也没有将任何自定义指标上传到Azure。

        TelemetryClient client = new TelemetryClient();
        client.InstrumentationKey = "a valid key";
        client.GetMetric("test me").TrackValue(200);
        client.Flush();
        Thread.Sleep(5000);

由于检测键配置不正确,导致此问题。

当使用GetMetric().TrackValue() ,我们应该使用这种方式来配置检测键:

TelemetryConfiguration.Active.InstrumentationKey = "your key" ;

我的代码如下:

  TelemetryClient client = new TelemetryClient();
  TelemetryConfiguration.Active.InstrumentationKey = "your key";  
  client.GetMetric("test33").TrackValue(100);  

  System.Threading.Thread.Sleep(1000*5);
  client.Flush();

  Console.WriteLine("Hello World!");
  Console.ReadLine();

然后在visual studio输出窗口中,您可以看到ikey显示在其中: 在此处输入图片说明

然后转到azure门户->应用程序见解->指标,您可以看到您的指标: 在此处输入图片说明

为了进行比较,当您使用以下代码时:

client.InstrumentationKey = "a valid key";
client.GetMetric("test me").TrackValue(200);

执行后,在Visual Studio中,您可以看到输出窗口中没有ikey,因此不会将度量标准发送到azure门户: 在此处输入图片说明

多亏了Ivan Yang,我找到了一个github问题,正在详细讨论这个问题。

似乎有多种情况创建无效的配置。

例如,当前这也是无效的配置

TelemetryConfiguration tcConfig = new TelemetryConfiguration();

TelemetryClient tc = new TelemetryClient(tcConfig)
{
    InstrumentationKey = ikey
};

https://github.com/Microsoft/ApplicationInsights-dotnet/issues/826https://www.reddit.com/r/Unity3D/comments/8igabt/using_microsoft_azure_app_insights_and_unity/上的更多详细信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM