Roteiro de consulta do SQL para Azure Monitor logSQL to Azure Monitor log query cheat sheet

A tabela a seguir ajuda os usuários que estão familiarizados com o SQL a aprender a linguagem de consulta Kusto para gravar consultas de log em Azure Monitor.The table below helps users who are familiar with SQL to learn the Kusto query language to write log queries in Azure Monitor. Observe o comando T-SQL para a solução de cenários comuns e o equivalente em uma consulta Azure Monitor log.Have a look at the T-SQL command for solving common scenarios and the equivalent in an Azure Monitor log query.

SQL para Azure MonitorSQL to Azure Monitor

DescriçãoDescription Consulta SQLSQL Query Azure Monitor consulta de logAzure Monitor log query
Selecionar todos os dados de uma tabelaSelect all data from a table SELECT * FROM dependencies dependencies
Selecionar colunas específicas de uma tabelaSelect specific columns from a table SELECT name, resultCode FROM dependencies dependencies
| project name, resultCode
Selecionar registros de 100 de uma tabelaSelect 100 records from a table SELECT TOP 100 * FROM dependencies dependencies
| take 100
Avaliação nulaNull evaluation SELECT * FROM dependencies WHERE resultCode IS NOT NULL dependencies
| where isnotnull(resultCode)
Comparação de cadeia de caracteres: igualdadeString comparison: equality SELECT * FROM dependencies WHERE name = "abcde" dependencies
| where name == "abcde"
Comparação de cadeia de caracteres: substringString comparison: substring SELECT * FROM dependencies WHERE name like "%bcd%" dependencies
| where name contains "bcd"
Comparação de cadeia de caracteres: curingaString comparison: wildcard SELECT * FROM dependencies WHERE name like "abc%" dependencies
| where name startswith "abc"
Comparação de datas: último diaDate comparison: last 1 day SELECT * FROM dependencies WHERE timestamp > getdate()-1 dependencies
| where timestamp > ago(1d)
Comparação de datas: intervalo de datasDate comparison: date range SELECT * FROM dependencies WHERE timestamp BETWEEN '2016-10-01' AND '2016-11-01' dependencies
| where timestamp between (datetime(2016-10-01) .. datetime(2016-10-01))
Comparação de boolianoBoolean comparison SELECT * FROM dependencies WHERE !(success) dependencies
| where success == "False"
| where success == "False"
OrdenarSort SELECT name, timestamp FROM dependencies ORDER BY timestamp asc dependencies
| order by timestamp asc
| order by timestamp asc
DistinçãoDistinct SELECT DISTINCT name, type FROM dependencies dependencies
| summarize by name, type
| summarize by name, type
Agrupamento, agregaçãoGrouping, Aggregation SELECT name, AVG(duration) FROM dependencies GROUP BY name dependencies
| summarize avg(duration) by name
| summarize avg(duration) by name
Aliases de coluna, estenderColumn aliases, Extend SELECT operation_Name as Name, AVG(duration) as AvgD FROM dependencies GROUP BY name dependencies
| summarize AvgD=avg(duration) by operation_Name
| project Name=operation_Name, AvgD
N principais registros por medidaTop n records by measure SELECT TOP 100 name, COUNT(*) as Count FROM dependencies GROUP BY name ORDER BY Count asc dependencies
| summarize Count=count() by name
| top 100 by Count asc
UniãoUnion SELECT * FROM dependencies UNION SELECT * FROM exceptions union dependencies, exceptions
União: com condiçõesUnion: with conditions SELECT * FROM dependencies WHERE value > 4 UNION SELECT * FROM exceptions WHERE value < 5 dependencies
| where value > 4
| union (exceptions
| where value < 5)
AssociarJoin SELECT * FROM dependencies JOIN exceptions ON dependencies.operation_Id = exceptions.operation_Id dependencies
| join (exceptions) on operation_Id == operation_Id

Passos seguintesNext steps