簡體   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