Search code examples
azureazure-application-insightscross-reference

Application Insights - How to refer All Tables in a Cross Reference Query


I'm have multiple Application Insights being referred by related multiple API apps as shown below. API1 - AI1 (Application 1 links to Application Insights 1 named ai1) API2 - AI2 (Application 2 links to Application Insights 2 named ai2) API3 - AI3 (Application 3 links to Application Insights 3 named ai3) and so on. API1 calls API2 which calls API3 Now, I need to pull ALL the information (ex: Requests, Dependencies, Events etc) from All the three Application Insights in a cross reference query.

union     
(
app('ai1').requests
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai1').dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai2').requests
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai2').dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai3').requests
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai3').dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
)

The above query perfectly works. As you might notice the query is not precise. Is there a way, I can union all type of tables into one so that my query is simple and precise something as shown below.

union 
(
app('ai1').**union**
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai2').**union**
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai3').**union**
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
)

Solution

  • Actually, you cannot union all type of tables into one, like using app('ai1').**union**. The requests, dependencies etc. must be explicitly specified. And please correct me if I misunderstood you.

    Alternative, you can use the query like below:

    union 
    (
     union app("ai1").requests, app("ai1").dependencies
     | where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
    ),
    (
     union app("ai2").requests, app("ai2").dependencies
     | where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
    ),
    (
     union app("ai3").requests, app("ai3").dependencies
     | where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
    )