0

I am using the logging extension framework in an asp.net core function app. I have following code:

log.LogMetric("TESTER", 0);
 
log.LogInformation($"{{logTypeStart}}: {service.GetType()}", logTypeStart);
await service.Run(log);
log.LogInformation($"{{logTypeEnd}}: {service.GetType()}", logTypeEnd);

In log analytics I query following:

AppTraces
AppMetrics

The LogInformation logs traces to the AppTraces in Log Analytics. But AppMetrics does not provide any results. Any pointers on how to troubleshoot this?

Thomas Segato
  • 4,567
  • 11
  • 55
  • 104
  • is it a function v3? and are you using the ILogger to log messages? it's better to providing more code(like a sample which we can use to repro/debug). – Ivan Glasenberg Nov 05 '20 at 00:41

1 Answers1

0

I tested it with Function V3, the metrics can be sent to both AI and the connected Log Analytics.

Please check the things below:

1.Test your code first locally(please follow this thread to see how azure function and application insights works locally), and see if the metrics can be shown in visual studio output. The screenshot is as below:

enter image description here

2.Please make sure the Azure log Analytics is actually connected with the AI you're using.

3.In Azure log Analytics, when query in AppMetrics table, make sure you have selected the proper time range. Here is the screenshot of my metrics:

enter image description here

Please let me know if any more issues.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • Thanks, appreciated. LogMetric is working with asp.net core applications because Microsoft.Azure.WebJobs.Extensions.Storage are installed. However in my sample I am working from a .NET standard library. I can log everything else fine, but I simply get a compiler error that LogMetric is not part of the framework, unless I am in an asp.net core project. – Thomas Segato Nov 05 '20 at 07:16
  • @ThomasSegato, ok. you should mention that in your question. I see the issue is in .net core azure function in the question:). – Ivan Glasenberg Nov 05 '20 at 07:18
  • Yeah i will update. But the conclusion is that the Extension Framework does not include logmetric :( ? – Thomas Segato Nov 05 '20 at 07:18
  • @ThomasSegato, you can directly use the TrackMetric or GetMetric method of AI SDK. – Ivan Glasenberg Nov 05 '20 at 07:19