7

I'm trying to create comments in my Azure Log Analytics queries and I'm stumped. Part of my challenge I think is treating this system as if it were SQL, which it is clearly not. using "--" for instance results in a syntax error

traces 
| where severityLevel > 1
-- this is an example of a line comment
| where message !contains "DiagnosticsLogger.GetMethod contains message 1"  
| where message !contains "DiagnosticsLogger.GetMethod contains message 2"
| summarize by timestamp, message, severityLevel

Couldn't find anything for search term "Comment" either on the https://docs.loganalytics.io reference.

Matthew Thurston
  • 720
  • 5
  • 22

1 Answers1

23

// works for Azure Log Analytics queries

Pranshu Gupta
  • 634
  • 9
  • 13
  • 2
    Where is this documented? – sartoris May 13 '20 at 15:12
  • @sartoris If you look through Kusto Query Language docs https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/ you will see that // is what should be used as a comment sign in example scripts, also if you look at "SQL to Kusto cheat sheet" (https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/sqlcheatsheet) you will see that there they are translating SQL's "--" into "//"... But if you are looking for specific place where documentation says "//" is your comment sign - I was not able to find this :) – Mikhail Dec 27 '21 at 12:17
  • @sartoris though you can also see an explicit statement in Azure Data Explorer KQL cheat sheets here - https://techcommunity.microsoft.com/t5/azure-data-explorer-blog/azure-data-explorer-kql-cheat-sheets/ba-p/1057404 – Mikhail Dec 27 '21 at 12:29