Praveen Reddy
Praveen Reddy

Reputation: 7383

Application Insights Analytics doing sub selects

I am using this reference documentation for Application Insights.

How can I do a sub-select using the output of a different query?

//Query 1
Events 
| where  Timestamp >= ago(30min) and Data contains('SomeString')
| project TraceToken

//I would like to use the first query's output in the subselect here.
Events 
| where TraceToken in ({I would like to use the First query's output here.})

Is a join better in this scenario. Which would have better performance.

Upvotes: 2

Views: 7354

Answers (1)

Dmitry Matveev
Dmitry Matveev

Reputation: 2679

You can use let statement to achieve this.

Here is an example from the Analytics documentation, I hope this helps:

let topCities =  toscalar ( // convert single column to value
   requests
   | summarize count() by client_City 
   | top 4 by count_ 
   | summarize makeset(client_City));
requests
| where client_City in (topCities) 
| summarize count() by client_City;

Edit: By default the maximum number of elements returned by the makeset() function is 128. The MaxSetSize should be specified for larger dataSets.

Upvotes: 14

Related Questions