0
votes

I have an application built from a series of web servers and microservices, perhaps 12 in all. I would like to monitor and, importantly, map this suite of services in Applications Insights. Some of the services are built with Dot Net framework 4.6 and deployed as Windows services using OWIN to receive and respond to requests.

In order to get the instrumentation working with OWIN I'm using the ApplicationInsights.OwinExtensions package. I'm using a single instrumentation key across all my services.

When I look at my Applications Insights Application Map, it appears that all the services that I've instrumented are grouped into a single "application", with a few "links" to outside dependencies. I do not seem to be able to produce the "Composite Application Map" the existence of which is suggested here: https://docs.microsoft.com/en-us/azure/application-insights/app-insights-app-map.

I'm assuming that this is because I have not set a different "RoleName" for each of my services. Unfortunately, I cannot find any documentation that describes how to do so. My map looks as follow, but the big circle in the middle is actually several different microservices:

App Insights Map

I do see that the OwinExtensions package offers the ability to customize some aspects of the telemetry reported but, without a deep knowledge of the internal structure of App Insights telemetry, I can't figure out whether it allows the RoleName to be set and, if so, how to accomplish this. Here's what I've tried so far:

        appBuilder.UseApplicationInsights(
            new RequestTrackingConfiguration
            {
                GetAdditionalContextProperties = 
                    ctx =>
                        Task.FromResult(
                            new [] { new KeyValuePair<string, string>("cloud_RoleName", ServiceConfiguration.SERVICE_NAME) }.AsEnumerable()
                        )
            }
        );

Can anyone tell me how, in this context, I can instruct App Insights to collect telemetry which will cause a Composite Application Map to be built?

1

1 Answers

1
votes

The following is the overall doc about TelemetryInitializer which is exactly what you want to set additional properties to the collected telemetry - in this case set Cloud Rolename to enable application map. https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling#add-properties-itelemetryinitializer

Your telemetry initializer code would be something along the following lines...

public void Initialize(ITelemetry telemetry)
{

if (string.IsNullOrEmpty(telemetry.Context.Cloud.RoleName))
            {
                // set role name correctly here.
                telemetry.Context.Cloud.RoleName = "RoleName";
            }
}

Please try this and see if this helps.