简体   繁体   中英

Azure Application Insights Analytics Query on Union and Column Comparision

I have two custom events A and B . A will be having a row with 2 columns say C and D ( having datetime datatype ) . Custom Event B will be having rows with 2 columns E and F , out of which E will be having a datetime value and F will be integer value. Events A and B doesnt have any common columns

Now I want the result set to be having those rows in which occur between the time C and D .

For Example , I have values in Column C - "2016-09-03" Column D - "2016-09-11" Column E having multiple rows starting from "2016-08-01" till "2016-09-30". I want the result set to be having only rows with column E and F values that occurred between column C and D

let tab1 = customEvents | extend cws = todatetime(tostring(customDimensions.['ColumnC'])) , cwe =todatetime(tostring(customDimensions.['ColumnB'])) | where name  == "A" | project cws , cwe , name | limit 1  ;
let tab2 = customEvents | extend dt = todatetime(tostring(customDimensions.['E'])) | where  name == "B" |summarize F=count(name) by E=startofday(dt) | order by E asc | project E , F  ; 
union tab* |take 10 |project cws , cwe , name , E , F
|  where E > cws and E < cwe | project E , F

Since there are no common columns , I have tried to use Union statement and combined two tables but unable to get the desired result set .Any inputs on this problem will be really helpful to me .

When you want to join 2 data sets which have no common column, you can create a dummy column. Try this query:

customEvents 
| where name  == "A"
| extend cws = todatetime(tostring(customDimensions.['ColumnC'])) , cwe =todatetime(tostring(customDimensions.['ColumnB'])), dummy = "dummy" | project cws , cwe , name, dummy
| join kind = leftouter (
    customEvents 
    | where  name == "B" 
    | extend dt = todatetime(tostring(customDimensions.['E'])) | summarize F = count(name) by E=startofday(dt) | order by E asc | project E , F, dummy = "dummy"  
) on dummy 
|  where E > cws and E < cwe | project E , F

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM