SQL pro monitorování Azure tahák pro dotazy logSQL to Azure Monitor log query cheat sheet

Následující tabulka pomáhá uživatelům, kteří znají SQL učit jazyk dotaz Kusto psaní dotazů protokolu ve službě 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. Podíváme se na příkaz T-SQL pro řešení běžných scénářů a ekvivalent v dotazu protokolu Azure Monitor.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

PopisDescription Příkaz jazyka SQLSQL Query Azure Monitor dotaz protokoluAzure Monitor log query
Vyberte všechna data z tabulkySelect all data from a table SELECT * FROM dependencies dependencies
Vyberte konkrétní sloupce z tabulkySelect specific columns from a table SELECT name, resultCode FROM dependencies dependencies
| project name, resultCode
Vyberte 100 záznamů z tabulkySelect 100 records from a table SELECT TOP 100 * FROM dependencies dependencies
| take 100
Null hodnoceníNull evaluation SELECT * FROM dependencies WHERE resultCode IS NOT NULL dependencies
| where isnotnull(resultCode)
Porovnání řetězců: rovnostiString comparison: equality SELECT * FROM dependencies WHERE name = "abcde" dependencies
| where name == "abcde"
Porovnání řetězců: dílčí řetězecString comparison: substring SELECT * FROM dependencies WHERE name like "%bcd%" dependencies
| where name contains "bcd"
Porovnání řetězců: zástupných znakůString comparison: wildcard SELECT * FROM dependencies WHERE name like "abc%" dependencies
| where name startswith "abc"
Datum, porovnání: poslední 1 denDate comparison: last 1 day SELECT * FROM dependencies WHERE timestamp > getdate()-1 dependencies
| where timestamp > ago(1d)
Datum, porovnání: rozsah kalendářních datDate 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))
Logická porovnáníBoolean comparison SELECT * FROM dependencies WHERE !(success) dependencies
| where success == "False"
| where success == "False"
SeřaditSort 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
Seskupení, agregaceGrouping, Aggregation SELECT name, AVG(duration) FROM dependencies GROUP BY name dependencies
| summarize avg(duration) by name
| summarize avg(duration) by name
Názvy sloupců, rozšířeníColumn 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
Prvních n záznamů míruTop 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
SjednoceníUnion SELECT * FROM dependencies UNION SELECT * FROM exceptions union dependencies, exceptions
Sjednocení: s podmínkamiUnion: with conditions SELECT * FROM dependencies WHERE value > 4 UNION SELECT * FROM exceptions WHERE value < 5 dependencies
| where value > 4
| union (exceptions
| where value < 5)
PřipojitJoin SELECT * FROM dependencies JOIN exceptions ON dependencies.operation_Id = exceptions.operation_Id dependencies
| join (exceptions) on operation_Id == operation_Id

Další postupNext steps