0
votes

Created a custom event using Azure App Insights. This custom event has the property of logged in user.I am unable to slice "Page Views" metrics (out of box) by using User name property from the custom event. Please suggest how to relate custom event properties with the metrics (out of box) provided by Azure App Insights.

2

2 Answers

0
votes

If you want to slice PageViews by username (set as custom property), you need to set UserName to PageView (instead or in addition to custom event). Just set UserName.

Just replace the simple call to trackPageView in JavaScript snippet to something like: appInsights.trackPageView(title, url, {UserName: USERNAME})

0
votes

If you are talking about MVC server side events, then you need to create a custom TelemetryInitializer to add the user name property to the telemetry (be it an event or a page request or any telemetry). See https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/ and http://www.apmtips.com/blog/2014/12/01/telemetry-initializers/

My custom TelemetryInitializer has this line of code to set the Username property to the currently authenticated user name:

telemetry.Context.Properties["Username"] = Thread.CurrentPrincipal.Identity.Name;