KQL
Cheatsheet
1. Basic Query Format
Start with the table name followed by a series of query operators.
2. Filtering
Use
where
to filter results based on a condition.
3. Sorting
Use
order by
to sort results based on a column.
4. Aggregation
Use
summarize
to aggregate data.
5. Joining Tables
Use
join
to combine tables based on a related column.
6. Selecting Columns
Use
project
to select which columns to display.
7. Renaming Columns
Use
extend
orproject
withas
to rename columns.
8. Limiting Results
Use
take
to limit the number of results returned.
9. Calculating Time Difference
Use
datetime_diff
to calculate the difference between two datetime columns.
10. String Manipulation
Examples for Detection Query in KQL
1. Basic Query
2. Filter for a Specific Event ID
3. Retrieve Specific Columns
4. Count by Event ID
5. Filter and Sort by Time
6. Join Two Tables
7. Limit Results
8. Calculate Time Difference
9. String Concatenation
10. Filter with Multiple Conditions
11. Count Events per Computer
12. Filter for a Specific Time Range
13. Find Unique Values
14. Calculate Average
15. Group by Time Interval
16. Use of Case Statement
17. Filter with String Contains
18. Top N Entities
19. Calculate Percentage
20. Filter with Not Equal
Last updated