ApplicationInsights-node.js icon indicating copy to clipboard operation
ApplicationInsights-node.js copied to clipboard

customMetrics problems

Open skhilliard opened this issue 1 year ago • 6 comments

When upgrading from 2.x to 3.0.1, we are seeing a lot of warnings like this...

  • Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
  • Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec". The metric name should be a ASCII string with a length no greater than 255 characters. []
  • Invalid metric name: "\Process(??APP_WIN32_PROC??)\Private Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
  • Invalid metric name: "\Memory\Available Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
  • Invalid metric name: "\Processor(_Total)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
  • Invalid metric name: "\Process(??APP_WIN32_PROC??)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
  • Invalid metric name: "Redis Health Check". The metric name should be a ASCII string with a length no greater than 255 characters. []

The first 6 of these aren't generated by any metrics we are doing, which is odd. The last one is one that we are using. It seems like the code doesn't like the fact that we have spaces in the metric name, which was allowed before. I do still see these appearing in metrics though, so it seems like a false warning.

Also, it looks like different instances of these sometimes get aggregated with 3.x, which isn't good for metrics...for example:

image

vs. 2.x

image

skhilliard avatar May 03 '24 21:05 skhilliard

@skhilliard Those first 6 warnings are performance counters. You can disable them via configuration options in Application Insights if you don't need them and want to remove the warnings. A fix will be applied to the Azure Monitor Exporter that will remove these warnings.

Your last metric "Redis Health Check" is invalid because of added spaces. This is another effect of moving to OpenTelemetry under the hood in 3.X and something I believe is worth updating in the migration guide. Thank you for your input there!

If you want fine grain control of how metrics are collected, I'd suggest following the migration guide above and moving to the Azure Monitor OpenTelemetry. Application Insights version 3.X is intended to be an easy upgrade path for those who have basic instrumentations with 2.X, while if you want more control and the advantages of OpenTelemetry, it's best to take advantage of the Azure Monitor OpenTelemetry.

JacksonWeber avatar May 03 '24 23:05 JacksonWeber

@JacksonWeber Did you see my question regarding the metrics being "merged" into one value? E.g. instead of 4 Redis Health Check items with value of one, they are combined into one with a value of 4?

skhilliard avatar May 24 '24 21:05 skhilliard

@skhilliard Apologies for the missed answer there. Regarding the aggregated metric, you have two options with the 3.X SDK.

  1. You could change to using a custom event here if you just need to record that the health check was reported at a timestamp. This will save money on reporting fields you don't appear to use like valueMin, valueMax, etc.

  2. If you're using the metrics reported values or just need this health check to be reported in the custom metrics table, you could use the Azure Monitor OpenTelemetry package and apply an Observable Gauge to capture these custom metrics instead of this package.

Please let me know if you have questions about either of these approaches. Thanks!

JacksonWeber avatar May 30 '24 16:05 JacksonWeber

@JacksonWeber Again, sorry for the delay in my response...

It seems like the easiest thing to do here would be to log these things as events instead. That seems to prevent data getting "merged" as well as allows us to keep the names as is (e.g. with spaces in them, etc.). Here are some examples from app insights:

image

Thanks, Kelly

skhilliard avatar Aug 07 '24 20:08 skhilliard

This Issue will be closed in 30 days. Please remove the "Stale" label or comment to avoid closure with no action.

github-actions[bot] avatar Jun 04 '25 07:06 github-actions[bot]

@JacksonWeber OpenTelemetry had naming guidelines that should be triggering here https://opentelemetry.io/docs/specs/semconv/general/naming/

hectorhdzg avatar Jun 04 '25 22:06 hectorhdzg

These warnings have been completely cleaned up as of the latest version of ApplicationInsights. Closing the issue as complete.

JacksonWeber avatar Sep 25 '25 22:09 JacksonWeber