Georgy Kitirisov
Georgy Kitirisov

Reputation: 1

How to combine requests to different services in different Application Insights Instances or analyze them together

Let there be such a backend api structure:
1. Standalone server #1 with accounts data. It has its own AI instrumentation key.
2. Standalone server #2 with order data. It has its own AI instrumentation key.
3. Standalone server #3 with Courier service data. It has its own AI instrumentation key.

Requests from client come to server #2. It makes requests to its own DB and other resources, and through the HTTP to servers #1, #3. Servers #1 and #3 make requests to its own DB and other resources and to each other through the HTTP.

How can I combine its requests in AI Explorer in Azure Portal in one trace or analyze them together from the moment of client request to server #2 to the moment of response to the Client?

Upvotes: 0

Views: 1531

Answers (2)

Peter Bons
Peter Bons

Reputation: 29870

You can't yet. You will have to use one Application Insights resource. You can then subdivide telemetry using custom properties or tags, see this blogpost:

... if you want to compare the telemetry between them. For example, you might be running the same app on multiple clusters and want to compare their performance; or you might build an on-prem app and want every telemetry item from each on-prem installation to be tagged with CustomerID. The Application Insights SDK lets you do this by tagging all the telemetry sent from a particular environment with arbitrary tags. Then in Metrics Explorer or Diagnostic Search, you can choose to see the data either aggregated all-up, or segmented or filtered by tag value.

An alternative might be using multi component applications like outlined here:

The key technique here is to send telemetry from every component in your application to the same Application Insights resource, but use the cloud_RoleName property to distinguish components when necessary. The Application Insights SDK adds the cloud_RoleName property to the telemetry components emit. For example, the SDK will add a web site name, or service role name to the cloud_RoleName property. You can override this value with a telemetryinitializer. The Application Map uses the cloud_RoleName property to identify the components on the map.

In some cases, this may not be appropriate, and you may prefer to use separate resources for different groups of components. For example, you might need to use different resources for management or billing purposes. Using separate resources means that you don't see all the components displayed on a single Application Map; and that you can't query across components in Analytics. You also have to set up the separate resources.

If you don't mind to do most of the work yourself you could use the rest api's of the different AI resources and glue something together in your own app/website

Upvotes: 0

Dmitry Matveev
Dmitry Matveev

Reputation: 2679

I think there is a preview out for cross-application queries, so one would be able to query in Application Insights Analytics across several resources. Here is an example query:

union app('fabrikamstage').requests, app('fabrikamprod').requests | where ..

With the latest AI .NET Web SDK, AI ASP.NET Core SDK, node.js SDK, the operation information is propagated between servers with the correlation headers, so associated telemetry will have the same Operation_Id across services allowing for easier querying.

Upvotes: 3

Related Questions