Table count from custom log

%3CLINGO-SUB%20id%3D%22lingo-sub-1624484%22%20slang%3D%22en-US%22%3ETable%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1624484%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20get%20the%20count%20of%20table%20name%20reference%20in%20my%20custom%20log%20which%20is%20pushed%20to%20the%20Log%20analytics.%20The%20custom%20log%20structure%20is%20given%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-basic%22%3E%3CCODE%3E020-08-31%2016%3A15%3A38%20ProxyEngine%20%5BINFO%5D%20api%20invoked%20by%20user%20abcd%20with%20db%20user%20as%20default%20api%20user%0A2020-08-31%2016%3A15%3A38%20JdbcTemplateService%20%5BDEBUG%5D%20getting%20basic%20api%20user%20userapi%0A2020-08-31%2016%3A15%3A38%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20table_1%0A2020-08-31%2016%3A15%3A39%20%20SqlTrigger%20%5BINFO%5D%20total%20records%20found%20301%0A2020-08-31%2016%3A15%3A39%20%20SqlTrigger%20%5BINFO%5D%20done%20fetching%20of%20data%0A%0A2020-08-31%2016%3A15%3A50%20ProxyEngine%20%5BINFO%5D%20api%20invoked%20by%20user%20xyz%20with%20db%20user%20as%20default%20api%20user%0A2020-08-31%2016%3A15%3A50%20JdbcTemplateService%20%5BDEBUG%5D%20getting%20basic%20api%20user%20userapi%0A2020-08-31%2016%3A15%3A50%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20table_2%0A2020-08-31%2016%3A15%3A51%20%20SqlTrigger%20%5BINFO%5D%20total%20records%20found%20305%0A2020-08-31%2016%3A15%3A51%20%20SqlTrigger%20%5BINFO%5D%20done%20fetching%20of%20data%0A%0A2020-08-31%2016%3A16%3A02%20ProxyEngine%20%5BINFO%5D%20api%20invoked%20by%20user%20abcd%20with%20db%20user%20as%20default%20api%20user%0A2020-08-31%2016%3A16%3A02%20JdbcTemplateService%20%5BDEBUG%5D%20getting%20basic%20api%20user%20userapi%0A2020-08-31%2016%3A16%3A02%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20table_1%0A2020-08-31%2016%3A16%3A34%20%20SqlTrigger%20%5BINFO%5D%20total%20records%20found%20301%0A2020-08-31%2016%3A16%3A34%20%20SqlTrigger%20%5BINFO%5D%20done%20fetching%20of%20data%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20expected%20output%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%20height%3D%2230px%22%3ETable%20name%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%20height%3D%2230px%22%3Ecount%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%20height%3D%2230px%22%3Etable_1%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%20height%3D%2230px%22%3E2%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%20height%3D%2230px%22%3Etable_2%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%20height%3D%2230px%22%3E1%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20provide%20the%20KQL%20query%20to%20get%20the%20above%20output%3F%20thanks%20in%20advance.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1624484%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELog%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1624897%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1624897%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EYou%20can%20use%20%22parse-where%22%20like%20I%20did%20%3C%2FSPAN%3E%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA03KOwqAMBAFwF7wDg8rFTyFraW9RFk%25252F4GYlu8EPObyWtsOoMLVRTbiTRZFwuKDUnCsFwkc9XYZzsxU1ijkIo4C5cafBO6Y8S9DI7ML2ECaJ3soK4%25252F0rLy2seflhAAAA%2Ftimespan%2FP1D%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E.%20The%20short%20syntax%20is%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E...%7C%20parse-where%20LogText%20with%20*%20%22from%20%22%20table_name%0A%7C%20summarize%20count()%20by%20table_name%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ewhere%20LogText%20is%20the%20name%20of%20the%20field%20you%20analyze.%3C%2FP%3E%0A%3CP%3EThe%20command%20is%20documented%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fparsewhereoperator%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1624922%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1624922%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20should%20work%20for%20this%20specific%20case%20assuming%20you%20have%20only%202%20tables.%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CCUSTOMLOG_CL%3E%20is%20your%20custom%20logs%20ingested%20to%20LA%2C%20and%20%20is%20the%20column%20which%20includes%20the%20messages%20string.%3C%2FCUSTOMLOG_CL%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3ECustomLog_CL%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Eextend%3C%2FSPAN%3E%3CSPAN%3E%20TableName%20%3D%20iff(Col%20%3C%2FSPAN%3E%3CSPAN%3Ehas%3C%2FSPAN%3E%20%3CSPAN%3E%22table_1%22%3C%2FSPAN%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CSPAN%3E%22table_1%22%3C%2FSPAN%3E%3CSPAN%3E%2C%20iff(Col%20%3C%2FSPAN%3E%3CSPAN%3Ehas%3C%2FSPAN%3E%20%3CSPAN%3E%22table_2%22%3C%2FSPAN%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CSPAN%3E%22table_2%22%3C%2FSPAN%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E))%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20isnotempty(TableName)%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%20%3CSPAN%3Ecount%3C%2FSPAN%3E%3CSPAN%3E()%20%3C%2FSPAN%3E%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20TableName%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1634391%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1634391%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3Ba%20lot%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F54923%22%20target%3D%22_blank%22%3E%40Noa%20Kuperberg%3C%2FA%3E%26nbsp%3Bfor%20the%20suggestion%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1634520%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1634520%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F54923%22%20target%3D%22_blank%22%3E%40Noa%20Kuperberg%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20more%20help%20is%20it%20possible%20to%20filter%20count%20based%20on%20the%20month%20using%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ethe%20bin(TimeGenerated%2C%20%3C%2FSPAN%3E%3CSPAN%3E30%3C%2FSPAN%3E%3CSPAN%3Eday)%20will%20help%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%3ETablename%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3EJuly%20count%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3EAugust%20Count%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%3Etable_1%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E3%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E2%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%3Etable_2%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E2%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E10%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1639017%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1639017%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3Byes%2C%20but%20it%20will%20be%20displayed%20a%20bit%20differently.%20Easiest%20is%20to%20just%20add%20a%20month%20column%20-%20Run%20%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA62RXUvDMBSG7wf9D4debWODfrihE2%25252FUORRRYfVKhqTNaRtsmi1J94U%25252F3rTbRNgcdngTksOb55z3vLbneE7XOe%25252F6Lrj9gdsb%25252BBd2B%25252BzxLAskSxKU8Hb%25252FdPc8ASpyhBh1lLI8AREDJZrYHath7yF6Tol4kWK5GuYJM%25252F%25252B2DDJlwPK5%25252BEAK4QoKZfDL1RoWTKdAw02BKKAYkyLTlb6sHWvzQMMoQD7NiMYxyjmLTLvb4fXraAIJal1OGxLFom9adZjHMeq%25252BfzXLIGbSTM4UKMww0tCGWAoOmoQZvnu%25252F8NzDPC00yUBiJCRVEIsip%25252BA7vXqQP4fSHzhejVBIGNGTUtn1%25252Bd9UdtQTUnEP8%25252FyzOqnUhBxOxWpMLq2GEhxvCqUFfxSJAqvxCVMiFXYXKUoEUwxwqTe7b4NdObG3XnLCsfxgBGjm4iLX6ZXZZnVpBozjCHOzRI20VepUwTmRbI0QGSO62SrzrcSdH8Qv2z%25252B3ZQMEAAA%25253D%2Ftimespan%2FP1D%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%20to%20play%20with%20it%20(I'm%20assuming%20the%20datetime%20information%20is%20ingested%20to%20the%20TimeGenerated%20field%2C%20which%20is%20typically%20what%20happens).%20The%20query%20text%20is%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E...%0A%7C%20parse-where%20LogText%20with%20*%20%22from%20%22%20table_name%0A%7C%20extend%20month%3Dgetmonth(TimeGenerated)%0A%7C%20summarize%20count()%20by%20month%2C%20table_name%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%20in%20ithis%20case%20the%20results%20would%20be%3A%3C%2FP%3E%0A%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3Emonth%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3Etable_name%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3Ecount_%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3E8%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3Etable_1%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3E2%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3E8%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3Etable_2%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2229px%22%3E1%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3ETo%20create%20a%20column%20for%20each%20month%2C%20append%20%22%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%7C%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3Eevaluate%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20pivot%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3Emonth%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E)%22%20to%20the%20query%20and%20you'll%20get%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%3Etable_name%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%3Ecount_%3C%2FTD%3E%0A%3CTD%20width%3D%2216.666666666666668%25%22%3E8%3C%2FTD%3E%0A%3CTD%20width%3D%2216.666666666666668%25%22%3E7%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%3Etable_1%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%3E2%3C%2FTD%3E%0A%3CTD%20width%3D%2216.666666666666668%25%22%3E1%3C%2FTD%3E%0A%3CTD%20width%3D%2216.666666666666668%25%22%3E...%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%3Etable_2%3C%2FTD%3E%0A%3CTD%20width%3D%2233.333333333333336%25%22%3E1%3C%2FTD%3E%0A%3CTD%20width%3D%2216.666666666666668%25%22%3E1%3C%2FTD%3E%0A%3CTD%20width%3D%2216.666666666666668%25%22%3E...%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3BOf%20course%20with%20more%20data%20you'll%20have%20additional%20columns%20for%20the%20other%20months.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1641119%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1641119%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F54923%22%20target%3D%22_blank%22%3E%40Noa%20Kuperberg%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%26nbsp%3B%3CSPAN%3E%26nbsp%3Bthe%20datetime%20information%20is%20ingested%20to%20the%20TimeGenerated%20field%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20tried%20with%20%22%3CSPAN%3Eevaluate%3C%2FSPAN%3E%3CSPAN%3E%20pivot(month)%22%20function%20but%20am%20getting%20some%20random%20value%20like%20%221%22%20and%20%220%22%20as%20output.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7C%20parse%20RawData%20with%20*%20%22from%20(%22%20from%20%22from%20%22%20Tablename%20%22where%22%20clause%0A%7C%20extend%20month%3Dgetmonth(TimeGenerated)%0A%7C%20summarize%20Count%3Dcount()by%20month%2C%20Tablename%20%0A%7C%20evaluate%20pivot(month)%0A%7C%20order%20by%20Count%20desc%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20the%20link%20you%20provided%20to%20play%20with%20am%20getting%20below%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EQuery%20could%20not%20be%20parsed%20at%20'%2C'%20on%20line%20%5B1%2C21%5D%20Token%3A%20%2C%20Line%3A%201%20Position%3A%2021%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThanks%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1641256%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1641256%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20to%20run%20it%20without%20summarizing%20before%20pivot%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EsomeCustomLogs%20%0A%7C%20parse-where%20LogText%20with%20*%20%22from%20%22%20TableName%0A%7C%20extend%20month%3Dgetmonth(TimeGenerated)%0A%7C%20project%20TableName%2C%20month%0A%7C%20evaluate%20pivot(month)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20reason%20that%20you've%20got%20the%20error%20in%20the%20link%20is%20that%20the%20'let'%20statement%20which%20defines%20the%20data%20table%20somehow%20wasn't%20complete%2C%20try%20it%20again%3A%20%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA62T30vDMBDH3wv9H44%25252BbbJBuznRii%25252FqFEVUcD6NIWlz7aJpM5Pr3MQ%25252F3jTbFHWKEymE5nL3uR9fTiKBUQUeVYZUcaFyAwfAGdkvkQiNgSjwFEvUjJDH9QuSNUELrO8AZxQb0qLMoel7w6ATdsJ2uNvuRhDtxFEv7u4FLQhuHuVAizxHDcOzy5OrEXBVImRI6biOVZlLGbR87yuiF9aIa61m836ZCxu3ZLCJAFFO1QNySOZQGYufzZ%25252FhSdAYeLIwMAMcM1ZJcv617ac05zxJB1hMpO3zBvVUpDbdcf%25252Fw9nQEORLV1SbMiPSN5g57%25252BYn6tX%25252FzKCET2lYuDBiUmBJsQaZVAW7wd51veNF6HiliEjSmSnMDmapKDt2wtxnk16LsxGFnA1FYkvI%25252FqbLK87%25252BqrKh%25252FUCVaz%25252Btub6LKhpD1qvjeaN%25252F3Pm2u773AhGmD7acxalyt6GL2WxC4ToJlLyUrsA6wDmjrKlRJ4wM7Tffzce%25252BbDqzVfT2Q9%25252BjWIshBpkxW1hUmYqqo4ezNV%25252FGR%25252FpFcBAAA%2Ftimespan%2FP1D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1641511%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1641511%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20query%20you%20have%20provided%20is%20working%20fine.%20But%20totalcount%20and%20Ordering%20is%20not%20working.%20Is%20it%20possible%20to%20include%20Totalcount%20and%20Descending%20order%20in%20the%20query%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1641739%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1641739%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20straight-forward%20way%20of%20doing%20it%3A%3C%2FP%3E%0A%3CP%3E1.%20Sort%20columns%20with%20project-reorder%20operator%20(had%20to%20manipulate%20the%20months%20to%20be%20from%20type%20string%20in%20order%20to%20enable%20sorting%20properly).%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eproject-reorder%3C%2FSTRONG%3E%20documentation%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fprojectreorderoperator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fprojectreorderoperator%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E2.%20Use%20join%20to%20combine%20the%20results%20from%20total%20aggregation%2C%20and%20the%20part%20where%20you%20split%20by%20month%20(I%20believe%20that%20there%20is%20a%20simpler%20whey%20to%20implement%20this)%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Ejoin%3C%2FSTRONG%3E%20documentation%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fjoinoperator%3Fpivots%3Dazuredataexplorer%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fjoinoperator%3Fpivots%3Dazuredataexplorer%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Elet%20TotalCount%20%3D%20someCustomLogs%20%0A%7C%20parse-where%20LogText%20with%20*%20%22from%20%22%20table_name%0A%7C%20summarize%20total%20%3D%20count()%20by%20table_name%3B%0AsomeCustomLogs%20%0A%7C%20parse-where%20LogText%20with%20*%20%22from%20%22%20table_name%0A%7C%20extend%20month%3D(getmonth(TimeGenerated))%0A%7C%20project%20table_name%2C%20month_str%20%3D%20iif(month%26lt%3B10%2C%20strcat('0'%2Ctostring(month))%2C%20tostring(month))%20%2F%2F%20Manipulating%20month%20into%20string%20to%20sort%20it%20with%20project-reorder%0A%7C%20evaluate%20pivot(month_str)%0A%7C%20join%20(TotalCount)%20on%20table_name%20%2F%2F%20Adding%20total%20count%20column%20-%20combine%20tables%20according%20to%20table_name%0A%7C%20project-away%20table_name1%0A%7C%20project-reorder%20table_name%2C%20total%2C%20*%20asc%20%2F%2F%20Sort%20columns%0A%7C%20order%20by%20table_name%20asc%20%2F%2F%20Sort%20rows%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1642840%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1642840%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20the%20given%20query%20for%201%20month%20(8th%20month)%20and%20it%20worked.%20But%20when%20I%20added%20a%20log%20snippet%20for%207th%20month%20the%20output%20is%20wrong.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22k-grid-header%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202020-09-08%20at%208.53.04%20AM.jpg%22%20style%3D%22width%3A%20230px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F216936i1160BF5F0BBC0119%2Fimage-dimensions%2F230x73%3Fv%3D1.0%22%20width%3D%22230%22%20height%3D%2273%22%20title%3D%22Screen%20Shot%202020-09-08%20at%208.53.04%20AM.jpg%22%20alt%3D%22Screen%20Shot%202020-09-08%20at%208.53.04%20AM.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20added%20logs%20for%20the%206th%20month%20as%20well%20but%20now%20showing%20the%20below%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%2F%23blade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA62T30vDMBDH3wv9H44%25252BbbJBuznRii%25252FqFEVUcD6NIWlz7aJpM5Pr3MQ%25252F3jTbFHWKEymE5nL3uR9fTiKBUQUeVYZUcaFyAwfAGdkvkQiNgSjwFEvUjJDH9QuSNUELrO8AZxQb0qLMoel7w6ATdsJ2uNvuRhDtxFEv7u4FLQhuHuVAizxHDcOzy5OrEXBVImRI6biOVZlLGbR87yuiF9aIa61m836ZCxu3ZLCJAFFO1QNySOZQGYufzZ%25252FhSdAYeLIwMAMcM1ZJcv617ac05zxJB1hMpO3zBvVUpDbdcf%25252Fw9nQEORLV1SbMiPSN5g57%25252BYn6tX%25252FzKCET2lYuDBiUmBJsQaZVAW7wd51veNF6HiliEjSmSnMDmapKDt2wtxnk16LsxGFnA1FYkvI%25252FqbLK87%25252BqrKh%25252FUCVaz%25252Btub6LKhpD1qvjeaN%25252F3Pm2u773AhGmD7acxalyt6GL2WxC4ToJlLyUrsA6wDmjrKlRJ4wM7Tffzce%25252BbDqzVfT2Q9%25252BjWIshBpkxW1hUmYqqo4ezNV%25252FGR%25252FpFcBAAA%2Ftimespan%2FP1D%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ELog%20analytics%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1642926%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1642926%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20it%20here%20(I%20added%20some%20months)%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA61VbU%25252FbMBD%25252BXqn%25252F4ZQvNCgRSbt2rBsfNsYQ094kuk8IISe5tGZJXGynL2g%25252FfmcnhbYwtkIUKUrOvueeu8e%25252By1CDEjkel0qL%25252FIsYKziChGl6ogyhM%25252BI5nmKBkmlMhmYFNZnAA9o7woUeKi15MQa33bpwukE38INDvxdCOBiG%25252FWHvjeOBc36TjSQfj1HCxdm3T98vIREFQoo6nhhfkdqQjtduPYToBwbihxSL5Ukx5uRXY7ApB17MxC9MIFpCqQh%25252BsbyFOdcTSKLKwBQkmLIy03a%25252FsT0V5nMSxSPMpxnleY5yxmMK9%25252FHkw8%25252FTSxij1oZtxBSP79Dsi36eQn2Yv7rJIOWSmHMFCjOMNexDKkUOtvBX3b%25252FghY%25252FjaaFZBhJjIRMFqSiLBHpBfzeQ%25252FxZlMAy6O4jCojh5liqrOM2qskJ9hirh43i9V7uosiPIv1R57Yf9JvMivEHDeIcvxVu%25252FDQM%25252FfLGOW3jdJvMdNKxHw%25252FmG3Ub4tVuXb9utjKbHyBzyYzrbmibH1ihpt37DlEmF%25252FnyCElczo2oG%25252B%25252BBYSKcGLViOxkGVec4kv8X6%25252FhxBbNA7rmko91spfBPRaAPStcxFoSdHHeom9mtz7rmuhZbi2lTi3t%25252Br3K5oBBJLztOO%25252FX8XBh6QLWa6sxfseVpUM7JadV0Pti1wcABfWcGnJbU4c82tnRqpFlDPV%25252FMlpAZe51Oz8SVSc0FpU5mxrCS%25252BMOUzoTt33Cz7a8ELGud3YrkgirVUDIP3SVJFMlW3Nad3VuYF%25252BPSRR6bNWw8FLDY9rea1WdAVMTZn63KF62s16Y1S2rAe6cRUbNicm2yr%25252BMr4Vh4bR2BjqxRz9QfO24W%25252FzggAAA%25253D%25253D%2Ftimespan%2FP1D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorRafi_Rabo_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorRafi_Rabo_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20not%20sure%20why%20the%20results%20when%20you%20added%20log%20for%20the%207th%20month%20are%20wrong%2C%20I%20need%20more%20context%20here%20(maybe%20add%20a%20link%20to%20the%20query%20and%20explain%20why%20the%20result%20is%20wrong%3F).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20attach%20the%20link%20to%20the%20error%20again%20(the%20current%20link%20does%20not%20show%20any%20error)%2C%20or%20just%20write%20it%20here.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1643403%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1643403%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E!%3C%2FP%3E%0A%3CP%3EThe%20query%20itself%20is%20valid.%3C%2FP%3E%0A%3CP%3EIs%20it%20possible%20that%20the%20inegested%20data%20has%20a%20different%20format%20that%20what%20you%20(customer)%20used%20on%20your%20original%20question%3F%20TimeGenerated%20should%20be%20in%20UTC.%20A%20different%20formatting%20may%20cause%20%22getmonth%22%20to%20fail%20or%20return%20a%20wrong%20value.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1647784%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1647784%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot%2C%20it%20worked%20fine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20trying%20to%20extend%20this%20query%20to%20include%20a%20rawdata%20that%20contains%20the%20string%20%22from%22%20two%20times%3F%3C%2FP%3E%3CP%3EAn%20example%20SQL%20log%20snippet%20is%20given%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E2020-08-31%2016%3A15%3A38%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20value(sum%205s)%20as%20from%20table_1%0A2020-08-31%2016%3A15%3A38%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20value(sum%205s)%20as%20from%20table_1%0A2020-08-31%2016%3A15%3A38%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20value(sum%205s)%20as%20from%20table_1%0A2020-08-31%2016%3A15%3A50%20%20SqlTrigger%20%5BINFO%5D%20sql%20fired%20is%20select%20*%20from%20table_2%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExpected%20output%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3Etable_name%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3Etotal_count%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3E08%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3Etable_1%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3E3%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3E3%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3Etable_2%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3E1%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%20height%3D%2230px%22%3E1%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%3C%2FP%3E%3CP%3ERinshad%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1648133%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1648133%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20the%20extract()%20function%20to%20identify%20the%20desired%20pattern%20(%22table_%22%20%2B%20%3CNUMBER%3E%20in%20this%20case)%2C%20and%20just%20filter%20out%20the%20rows%20without%20match.%3C%2FNUMBER%3E%3C%2FP%3E%0A%3CP%3ELink%20to%20documentation%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fextractfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fextractfunction%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Elet%20TotalCount%20%3D%20someCustomLogs%0A%7C%20extend%20table_name%20%3D%20(extract%20(%22table_(%5B0-9%5D%2B)%22%2C%200%2C%20LogText))%0A%7C%20where%20isnotempty(table_name)%0A%7C%20summarize%20total%20%3D%20count()%20by%20table_name%3B%0AsomeCustomLogs%20%0A%7C%20extend%20table_name%20%3D%20(extract%20(%22table_(%5B0-9%5D%2B)%22%2C%200%2C%20LogText))%2C%20month%3D(getmonth(TimeGenerated))%0A%7C%20where%20isnotempty(table_name)%0A%7C%20project%20table_name%2C%20month_str%20%3D%20iif(month%26lt%3B10%2C%20strcat('0'%2Ctostring(month))%2C%20tostring(month))%20%2F%2F%20Manipulating%20month%20into%20string%20to%20sort%20it%20with%20project-reorder%0A%7C%20evaluate%20pivot(month_str)%0A%7C%20join%20(TotalCount)%20on%20table_name%20%2F%2F%20Adding%20total%20count%20column%20-%20combine%20tables%20according%20to%20table_name%0A%7C%20project-away%20table_name1%0A%7C%20project-reorder%20table_name%2C%20total%2C%20*%20asc%20%2F%2F%20Sort%20columns%0A%7C%20order%20by%20table_name%20asc%20%2F%2F%20Sort%20rows%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1651569%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1651569%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20we%20can%20do%20a%20string%20regression.%20For%20example%2C%20if%20the%20table%20name%20is%20as%20follows%20then%20how%20we%20can%20include%20it%20in%20the%20query.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20abc_3val_xyz_dd%3C%2FP%3E%3CP%3E2.%20txt_1data_abcd%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1652962%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1652962%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20can%20think%20of%20several%20options%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E1.%3C%2FSTRONG%3E%20Look%20for%20more%20patterns%20in%20the%20the%20extract()%20function%20(You%20may%20use%20more%20complex%20RegExp%20to%20match%20more%20tables).%20Note%20that%20this%20is%20not%20scalable%20solution%20since%20you'll%20always%20need%20to%20add%20more%20patterns%2F%20table%20names%20to%20the%20expression.%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7C%20extend%20table_name%20%3D%20(extract%20(%22(table_%5B0-9%5D%2B)%7C(abc_3val_xyz_dd)%7C(txt_1data_abcd)%22%2C%200%2C%20LogText))%2C%20month%3D(getmonth(TimeGenerated))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3E2.%3C%2FSTRONG%3E%20Add%20a%20'TableName'%20column%20to%20your%20custom%20logs%2C%20with%20the%20table%20name%20in%20the%20relevant%20rows.%20Easily%20you'll%20be%20able%20to%20filter%20out%20logs%20which%20are%20not%20related%20to%20tables%2C%20and%20summarize%20according%20to%20'TableName'.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E3.%3C%2FSTRONG%3E%20Write%20the%20message%20in%20your%20logs%20with%20a%20unique%20pattern%20for%20table%2C%20for%20example%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3E%22.......%20from%20....%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Eis%20select%20*%20%3CSTRONG%3Efrom%20table%3C%2FSTRONG%3E%20table_2%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EIn%20such%20case%20you%20could%20parse%20according%20to%20the%20unique%20pattern%20%22from%20table%20%22.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EHope%20that%20it%20answers%20your%20question%2C%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3ERafi%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1656033%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1656033%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20we%20have%20RegExp%20similar%20to%20below%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20abc_%5B0-9%5Dval_*%20(all%20string%20or%20word%20)after%20this%3F%3C%2FP%3E%3CP%3EExpected%20table%20names%3C%2FP%3E%3CP%3Eabc_1val_dd%3C%2FP%3E%3CP%3Eabc_3val_xx%3C%2FP%3E%3CP%3Eabc_2val_extra_cc%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1661483%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1661483%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20should%20work%3A%26nbsp%3B%20abc_%5B0-9%5D%2Bval_.%2B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20link%20to%20the%20%3CSPAN%3Eregular%20expression%20syntax%20supported%20by%20Kusto%3A%26nbsp%3B%20%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fgoogle%2Fre2%2Fwiki%2FSyntax%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fgoogle%2Fre2%2Fwiki%2FSyntax%3C%2FA%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ERafi%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1672017%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1672017%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20use%20the%20Regex%20you%20have%20provided%20I%20am%20getting%20all%20the%20value%20in%20the%20RawData%20along%20with%20the%20table%20name.%20I%20am%20not%20able%20to%20filter%20the%20exact%20table%20name%20from%20the%20RawData.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1672277%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1672277%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20running%20the%20following%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA0tMSo6PNtC1jNUuS8wBsxx1oxJ1q%25252BJjtQHZ%25252BCIAGwAAAA%25253D%25253D%2Ftimespan%2FP1D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20tweaked%20the%20regexp%20to%3A%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Eabc_%5B0-9%5D%2Bval_%5B0-9A-Za-z_%5D%2B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20still%20have%20issues%2C%20please%20share%20the%20data%20and%20query%20you%20are%20trying%20to%20run.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1673791%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1673791%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20notice%20that%20if%20I%20use%20a%20similar%20table%20name%20in%20the%20extend%20operator%20am%20getting%20same%20result.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Eextend%20table_name%20%3D%20(extract%20(%22(abc_8val_yy)%22%2C%200%2C%20RawData))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20output%20(count%20of%20table%20name)%20of%20above%20query%20and%20below%20query%20is%20same%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Eextend%20table_name%20%3D%20(extract%20(%22(abc_8val_yy_vw)%22%2C%200%2C%20RawData))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1674131%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1674131%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E%26nbsp%3B%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20behavior%20is%20expected%20since%20the%20string%20%22abc_8val_yy%22%20is%20a%20sub-string%20of%20%22abc_8val_yy_vw%22.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFollow%20the%20extract%20operator%20documentation%20for%20more%20details%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fextractfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fextractfunction%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1677597%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1677597%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691417%22%20target%3D%22_blank%22%3E%40Rafi_Rabo%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20fetch%20the%20exact%20matching%20string%20from%20Rawdata%20using%20%22extract%22%20operator%3F%20or%20any%20other%20command%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1677640%22%20slang%3D%22en-US%22%3ERe%3A%20Table%20count%20from%20custom%20log%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1677640%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F701665%22%20target%3D%22_blank%22%3E%40alchem_rj%3C%2FA%3E.%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20tweak%20the%20regular%20expression%2C%20using%20the%20operator%20%24%20which%20means%20end%20of%20match.%3C%2FP%3E%0A%3CP%3EIn%20your%20case%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-regex%22%3E%3CCODE%3Eextend%20table_name%20%3D%20(extract%20(%22(abc_8val_yy%24)%22%2C%200%2C%20RawData))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EReference%20for%20regular%20expressions%20supported%20in%20Kusto%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fgoogle%2Fre2%2Fwiki%2FSyntax%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fgoogle%2Fre2%2Fwiki%2FSyntax%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERafi%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

 

I would like to get the count of table name reference in my custom log which is pushed to the Log analytics. The custom log structure is given below.

 

020-08-31 16:15:38 ProxyEngine [INFO] api invoked by user abcd with db user as default api user
2020-08-31 16:15:38 JdbcTemplateService [DEBUG] getting basic api user userapi
2020-08-31 16:15:38  SqlTrigger [INFO] sql fired is select * from table_1
2020-08-31 16:15:39  SqlTrigger [INFO] total records found 301
2020-08-31 16:15:39  SqlTrigger [INFO] done fetching of data

2020-08-31 16:15:50 ProxyEngine [INFO] api invoked by user xyz with db user as default api user
2020-08-31 16:15:50 JdbcTemplateService [DEBUG] getting basic api user userapi
2020-08-31 16:15:50  SqlTrigger [INFO] sql fired is select * from table_2
2020-08-31 16:15:51  SqlTrigger [INFO] total records found 305
2020-08-31 16:15:51  SqlTrigger [INFO] done fetching of data

2020-08-31 16:16:02 ProxyEngine [INFO] api invoked by user abcd with db user as default api user
2020-08-31 16:16:02 JdbcTemplateService [DEBUG] getting basic api user userapi
2020-08-31 16:16:02  SqlTrigger [INFO] sql fired is select * from table_1
2020-08-31 16:16:34  SqlTrigger [INFO] total records found 301
2020-08-31 16:16:34  SqlTrigger [INFO] done fetching of data

 

The expected output 

 

Table namecount
table_12
table_21

 

Can someone provide the KQL query to get the above output? thanks in advance.

 

 

23 Replies

Hi @alchem_rj,

You can use "parse-where" like I did here. The short syntax is 

...| parse-where LogText with * "from " table_name
| summarize count() by table_name​

where LogText is the name of the field you analyze.

The command is documented here.

Thanks a lot, @Noa Kuperberg for the suggestion

Hi @Noa Kuperberg ,

 

One more help is it possible to filter count based on the month using 

 
the bin(TimeGenerated, 30day) will help?

 

TablenameJuly countAugust Count
table_132
table_2210

 

 

@alchem_rj yes, but it will be displayed a bit differently. Easiest is to just add a month column - Run this to play with it (I'm assuming the datetime information is ingested to the TimeGenerated field, which is typically what happens). The query text is:

...
| parse-where LogText with * "from " table_name
| extend month=getmonth(TimeGenerated)
| summarize count() by month, table_name

and in ithis case the results would be:

month table_name count_
8 table_1 2
8 table_2 1

To create a column for each month, append "| evaluate pivot(month)" to the query and you'll get:

table_name count_ 8 7
table_1 2 1 ...
table_2 1 1 ...

 Of course with more data you'll have additional columns for the other months.

Thanks @Noa Kuperberg ,

 

Yes,  the datetime information is ingested to the TimeGenerated field,

I tried with "evaluate pivot(month)" function but am getting some random value like "1" and "0" as output.

 

 

| parse RawData with * "from (" from "from " Tablename "where" clause
| extend month=getmonth(TimeGenerated)
| summarize Count=count()by month, Tablename 
| evaluate pivot(month)
| order by Count desc

 

 

Also, the link you provided to play with am getting below error.

 

Query could not be parsed at ',' on line [1,21] Token: , Line: 1 Position: 21

 

Thanks

Hi @alchem_rj ,

 

Try to run it without summarizing before pivot:

 

someCustomLogs 
| parse-where LogText with * "from " TableName
| extend month=getmonth(TimeGenerated)
| project TableName, month
| evaluate pivot(month)

 

The reason that you've got the error in the link is that the 'let' statement which defines the data table somehow wasn't complete, try it again: Go to Log Analytics and run query

 

Rafi

 

 

Hi @Rafi_Rabo 

 

Thanks a lot for your help.

 

The query you have provided is working fine. But totalcount and Ordering is not working. Is it possible to include Totalcount and Descending order in the query?

 

Thanks

@alchem_rj 

 

Here is a straight-forward way of doing it:

1. Sort columns with project-reorder operator (had to manipulate the months to be from type string in order to enable sorting properly).

project-reorder documentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/projectreorderoperator

2. Use join to combine the results from total aggregation, and the part where you split by month (I believe that there is a simpler whey to implement this)

join documentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/joinoperator?pivots=azuredataexplor...

 

let TotalCount = someCustomLogs 
| parse-where LogText with * "from " table_name
| summarize total = count() by table_name;
someCustomLogs 
| parse-where LogText with * "from " table_name
| extend month=(getmonth(TimeGenerated))
| project table_name, month_str = iif(month<10, strcat('0',tostring(month)), tostring(month)) // Manipulating month into string to sort it with project-reorder
| evaluate pivot(month_str)
| join (TotalCount) on table_name // Adding total count column - combine tables according to table_name
| project-away table_name1
| project-reorder table_name, total, * asc // Sort columns
| order by table_name asc // Sort rows

 

Rafi 

Hi @Rafi_Rabo ,

 

I tried the given query for 1 month (8th month) and it worked. But when I added a log snippet for 7th month the output is wrong.

 

 

Screen Shot 2020-09-08 at 8.53.04 AM.jpg

I added logs for the 6th month as well but now showing the below error.

 

Log analytics 

 

Thanks

Hi @alchem_rj,

 

Try it here (I added some months): Go to Log Analytics and run query

 
 

 

 

I'm not sure why the results when you added log for the 7th month are wrong, I need more context here (maybe add a link to the query and explain why the result is wrong?).

 

Please attach the link to the error again (the current link does not show any error), or just write it here.

 

Rafi

 

Thanks @Rafi_Rabo!

The query itself is valid.

Is it possible that the inegested data has a different format that what you (customer) used on your original question? TimeGenerated should be in UTC. A different formatting may cause "getmonth" to fail or return a wrong value. 

Hi @Rafi_Rabo ,

 

Thanks a lot, it worked fine.

 

We are trying to extend this query to include a rawdata that contains the string "from" two times?

An example SQL log snippet is given below.

 

2020-08-31 16:15:38  SqlTrigger [INFO] sql fired is select * from value(sum 5s) as from table_1
2020-08-31 16:15:38  SqlTrigger [INFO] sql fired is select * from value(sum 5s) as from table_1
2020-08-31 16:15:38  SqlTrigger [INFO] sql fired is select * from value(sum 5s) as from table_1
2020-08-31 16:15:50  SqlTrigger [INFO] sql fired is select * from table_2

 

Expected output

table_nametotal_count08
table_133
table_211

 

 

Thank

Rinshad

@alchem_rj 

 

You can use the extract() function to identify the desired pattern ("table_" + <number> in this case), and just filter out the rows without match.

Link to documentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/extractfunction

 

let TotalCount = someCustomLogs
| extend table_name = (extract ("table_([0-9]+)", 0, LogText))
| where isnotempty(table_name)
| summarize total = count() by table_name;
someCustomLogs 
| extend table_name = (extract ("table_([0-9]+)", 0, LogText)), month=(getmonth(TimeGenerated))
| where isnotempty(table_name)
| project table_name, month_str = iif(month<10, strcat('0',tostring(month)), tostring(month)) // Manipulating month into string to sort it with project-reorder
| evaluate pivot(month_str)
| join (TotalCount) on table_name // Adding total count column - combine tables according to table_name
| project-away table_name1
| project-reorder table_name, total, * asc // Sort columns
| order by table_name asc // Sort rows

 

Rafi

Hi @Rafi_Rabo,

 

How we can do a string regression. For example, if the table name is as follows then how we can include it in the query.

 

1. abc_3val_xyz_dd

2. txt_1data_abcd

 

Thanks

Hi @alchem_rj ,

 

I can think of several options:

1. Look for more patterns in the the extract() function (You may use more complex RegExp to match more tables). Note that this is not scalable solution since you'll always need to add more patterns/ table names to the expression.

| extend table_name = (extract ("(table_[0-9]+)|(abc_3val_xyz_dd)|(txt_1data_abcd)", 0, LogText)), month=(getmonth(TimeGenerated))

2. Add a 'TableName' column to your custom logs, with the table name in the relevant rows. Easily you'll be able to filter out logs which are not related to tables, and summarize according to 'TableName'.

3. Write the message in your logs with a unique pattern for table, for example

"....... from .... is select * from table table_2"
In such case you could parse according to the unique pattern "from table ".
 
Hope that it answers your question,
Rafi
 

Hi @Rafi_Rabo,

 

 

Do we have RegExp similar to below?

 

1. abc_[0-9]val_* (all string or word )after this?

Expected table names

abc_1val_dd

abc_3val_xx

abc_2val_extra_cc

 

Thanks

 

Hi @alchem_rj ,

 

The following should work:  abc_[0-9]+val_.+

 

Here is a link to the regular expression syntax supported by Kusto:   https://github.com/google/re2/wiki/Syntax 

 

Rafi

Hi @Rafi_Rabo ,

 

When I use the Regex you have provided I am getting all the value in the RawData along with the table name. I am not able to filter the exact table name from the RawData.

Hi @alchem_rj ,

 

Try running the following: Go to Log Analytics and run query

 

I tweaked the regexp to: 

abc_[0-9]+val_[0-9A-Za-z_]+

 

If you still have issues, please share the data and query you are trying to run.

 

Rafi