4

I currently have an api set up with the following route:

/api/v1.0/External/{id}/Player
/api/External/{id}/Player

When these URLs are hit by a client, we see many different URLs in Application Insights such as:

/api/v1.0/External/1/Player
/api/External/5/Player
/api/v1.0/External/7/Player
/api/External/1/Player
/api/v1.0/External/10/Player
/api/External/8/Player

When looking at failed operations, this makes looking for common errors in an endpoint very difficult when these are spread around.

Is there any way to get application insights to treat all of the above URLs are the same URL?

bizzehdee
  • 20,289
  • 11
  • 46
  • 76

1 Answers1

0

You can use ITelemetryProcessor to process data before it is sent to the portal. There, you can normalize the URL paths by your routing logic.

Another option is to search the raw data in Analytics, accessible from the button toolbar at the top of the Overview tab. There, you can use wildcards in place of the placeholder values to query by path.

Tsahi Asher
  • 1,767
  • 15
  • 28
  • ITelemetryProcessor would mean having to manually normalise 1000's of different URL's and would need constantly updating every time a new api is added, and analytics wont help, because if im summarizing by operation_Name, wildcards dont help – bizzehdee Sep 03 '19 at 08:56
  • @bizzehdee you can use regex to make a general search pattern, e.g. `/api/v1.0/External/(\d+)/Player` (didn't test), and replace the found token with `{id}` or whatever. But yes, maintenance would be a pain. Unless you'll find a way to share code with your routing, such as using the routing to reverse map from URL to an Action (I think there is such an API in MVC) – Tsahi Asher Sep 03 '19 at 10:24
  • What about the 1000s of other URLs? i dont just have 1 single api with 2 different endpoints in the system, there are 1000s of APIs. I was hoping that i would be able to know what controller and method were hit from within a telemetry initializer or processor, but it turns out that i cant. – bizzehdee Sep 03 '19 at 14:00
  • Perhaps [this](https://stackoverflow.com/questions/8830052/) will help? – Tsahi Asher Sep 04 '19 at 07:35