Forum Discussion
Pravin Ohal
Jun 22, 2018Copper Contributor
Union operator return results out of sequence in Azure Log Analytics Query
Hi, I'm working on the following query. The union will give me count of the message in out of sequence fashion always for e.g The expected behavior should be that it should return results a...
- Jul 20, 2018
Hi
I think probably the easier solution for this is :
let result1 = search in (traces) message : "New Request Received" and timestamp > ago(1d) | summarize count() | extend rank = 1; let result2 = search in (traces) message : "Listing Customers" and timestamp > ago(1d) | summarize count()| extend rank = 2; let result3 = search in (traces) message : "pqr" and timestamp > ago(1d) | summarize count()| extend rank = 3; result1 | union result2, result3 | sort by rank asc
Seems like union does not care on the order of how you stitch results. Probably this is done due to performance reasons.
Jul 20, 2018
Hi
I think probably the easier solution for this is :
let result1 = search in (traces) message : "New Request Received" and timestamp > ago(1d) | summarize count() | extend rank = 1; let result2 = search in (traces) message : "Listing Customers" and timestamp > ago(1d) | summarize count()| extend rank = 2; let result3 = search in (traces) message : "pqr" and timestamp > ago(1d) | summarize count()| extend rank = 3; result1 | union result2, result3 | sort by rank asc
Seems like union does not care on the order of how you stitch results. Probably this is done due to performance reasons.
- Pravin OhalJul 20, 2018Copper ContributorThanks Stanislav_Zhelyazkov.
- Jul 20, 2018
BTW it is good not to use search as this slows down queries. Query like this is better:
traces | where message has "xyz" and timestamp > ago(1d) | summarize count()