A maioria dos exemplos funciona na tabela SecurityEvent, mas você pode adaptar para outras tabelas (Syslog, SigninLogs, etc.).
Comentários
// Este é um comentário
Operador where e Pipe |
- where filtra linhas de uma tabela.
- | (pipe) separa operadores e encadeia transformações.
SecurityEvent
| where Computer has “contosohotels.com”
| count
Filtros por Tempo
- Sempre aplique filtros de tempo no início da consulta para ganhar performance.
// Últimas 24h
SecurityEvent
| where TimeGenerated > ago(24h)
// Entre horários específicos
SecurityEvent
| where TimeGenerated between(datetime(2025-08-25 00:00:00) .. datetime(2025-08-25 06:00:00))
Seleção de Colunas (project)
// Escolher colunas
SecurityEvent
| project TimeGenerated, EventID, Account, Computer
// Renomear colunas
SecurityEvent
| project UserName = Account, Computer, LogonType
// Remover colunas
SecurityEvent
| project-away EventSourceName, Task
Contagem de Registros
SecurityEvent | count
Busca Global
search “*KEYWORD*”
Igualdade e Comparação
- Igual: ==
- Diferente: !=
- Maior/Menor: >, <, >=, <=
SecurityEvent
| where ProcessName == @”C:\Windows\System32\svchost.exe”
SecurityEvent
| where EventID != 4624
Operadores de String
// Contém (case insensitive por padrão)
SecurityEvent
| where CommandLine contains “guest”
// Mais performático: has
SecurityEvent | where Computer has “america”
// Início ou Fim
SecurityEvent | where Computer startswith “DC”
SecurityEvent | where Computer endswith “.local”
// Regex
SecurityEvent | where Computer matches regex @”\.contoso.+”
Lógico (AND, OR, NOT)
SecurityEvent | where EventID == 4624 and LogonType == 3
SecurityEvent | where EventID == 4624 or EventID == 4625
SecurityEvent | where not(EventID == 4624)
Agregações (summarize)
// Contagem por usuário
SecurityEvent
| summarize count() by Account
// Top 10 pacotes de autenticação
SecurityEvent
| where EventID == 4624
| summarize qtd = count() by AuthenticationPackageName
| top 10 by qtd desc
Concatenação
SecurityEvent
| project exemplo = strcat(EventID, ” – “, Channel)
Visualizações (render)
SecurityEvent
| summarize total = count() by EventID
| render columnchart

Seja o primeiro a comentar