SQL naar Azure Monitor log-query-CheatsheetSQL to Azure Monitor log query cheat sheet

De onderstaande tabel helpt gebruikers die bekend met SQL zijn voor meer informatie over de Kusto-querytaal voor het schrijven van Logboeken-query's in 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. Bekijk de T-SQL-opdracht voor het oplossen van veelvoorkomende scenario's en de overeenkomstige waarde in een query voor Azure Monitor hebben.Have a look at the T-SQL command for solving common scenarios and the equivalent in an Azure Monitor log query.

SQL Azure monitorSQL to Azure Monitor

DescriptionDescription SQL-QuerySQL Query Azure Monitor log-queryAzure Monitor log query
Alle gegevens uit een tabel selecterenSelect all data from a table SELECT * FROM dependencies dependencies
Selecteer specifieke kolommen uit een tabelSelect specific columns from a table SELECT name, resultCode FROM dependencies dependencies
| project name, resultCode
100 records uit een tabel selecterenSelect 100 records from a table SELECT TOP 100 * FROM dependencies dependencies
| take 100
Null-evaluatieNull evaluation SELECT * FROM dependencies WHERE resultCode IS NOT NULL dependencies
| where isnotnull(resultCode)
Vergelijking van de tekenreeks: gelijkheidString comparison: equality SELECT * FROM dependencies WHERE name = "abcde" dependencies
| where name == "abcde"
Vergelijking van de tekenreeks: subtekenreeksString comparison: substring SELECT * FROM dependencies WHERE name like "%bcd%" dependencies
| where name contains "bcd"
Vergelijking van de tekenreeks: jokertekensString comparison: wildcard SELECT * FROM dependencies WHERE name like "abc%" dependencies
| where name startswith "abc"
Datum van de vergelijking: afgelopen dagDate comparison: last 1 day SELECT * FROM dependencies WHERE timestamp > getdate()-1 dependencies
| where timestamp > ago(1d)
Datum van de vergelijking: datumbereikDate 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))
Boole-vergelijkingBoolean comparison SELECT * FROM dependencies WHERE !(success) dependencies
| where success == "False"
| where success == "False"
SorterenSort SELECT name, timestamp FROM dependencies ORDER BY timestamp asc dependencies
| order by timestamp asc
| order by timestamp asc
DistinctDistinct SELECT DISTINCT name, type FROM dependencies dependencies
| summarize by name, type
| summarize by name, type
Grouping, AggregationGrouping, Aggregation SELECT name, AVG(duration) FROM dependencies GROUP BY name dependencies
| summarize avg(duration) by name
| summarize avg(duration) by name
Kolomaliassen uitbreidenColumn 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
Top n-records door de metingTop 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
UnionUnion SELECT * FROM dependencies UNION SELECT * FROM exceptions union dependencies, exceptions
Union: met de voorwaardenUnion: with conditions SELECT * FROM dependencies WHERE value > 4 UNION SELECT * FROM exceptions WHERE value < 5 dependencies
| where value > 4
| union (exceptions
| where value < 5)
DeelnemenJoin SELECT * FROM dependencies JOIN exceptions ON dependencies.operation_Id = exceptions.operation_Id dependencies
| join (exceptions) on operation_Id == operation_Id

Volgende stappenNext steps