Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to join on customDimensions in Application Insights Analytics?

When I try to join on one of the customDimensions fields, I get a syntax error: "join attributes may be only column entity or equality expressions". I am able to join on non-custom columns such as name or timestamp.

Sample code:

let ExperimentLaunchedEvents = customEvents | where name=="ExperimentLaunched" and timestamp > now(-30d);  

let ExperimentTerminatedEvents = customEvents | where name=="ExperimentTerminated" and timestamp > now(-30d); 

ExperimentLaunchedEvents  
    | project name, timestamp, experimentId=customDimensions.ExperimentId  
    | join kind=leftanti (ExperimentTerminatedEvents  
                            | project name, timestamp, experimentId=customDimensions.ExperimentId) on tostring(experimentId)  

If joining on customDimensions columns is not supported, is there any way to achieve selecting launched experiments that haven't been terminated? Thanks!

like image 354
ZhenyaR Avatar asked Jan 12 '17 18:01

ZhenyaR


People also ask

How do I log custom events in application insights?

In the Azure Portal, navigate to the Application Insights resource, and click Log Analytics. Log queries help you to fully leverage the value of the data collected in Azure Monitor Logs. Query your custom events by entering “customEvents” in the prompt and click Run.

What are events in application insights?

In Application Insights, a custom event is a data point that you can display in Metrics Explorer as an aggregated count and in Diagnostic Search as individual occurrences. (It isn't related to MVC or other framework "events.") Insert TrackEvent calls in your code to count various events.

What is application insights telemetry?

Application Insights telemetry model defines a way to correlate telemetry to the operation of which it's a part. For example, a request can make a SQL Database calls and recorded diagnostics info. You can set the correlation context for those telemetry items that tie it back to the request telemetry.


1 Answers

As mentioned by John in the comments When using custom dimensions for any operations you need to convert it to a type that can be used by the query engine. In this case I use tostring(), but you can also use other functions like toint().

I also extend a column type so it can be reused in clauses like join or where without having to use the long hand over and over again.

ExperimentLaunchedEvents
| extend experimentId=tostring(customDimensions.ExperimentId)
| project name, timestamp, experimentId
| join kind=leftanti (ExperimentTerminatedEvents
| extend experimentId=tostring(customDimensions.ExperimentId)
| project name, timestamp, experimentId)
on experimentId
like image 68
James Davis - MSFT Avatar answered Oct 04 '22 18:10

James Davis - MSFT