Module 6 -V2: Create queries for Microsoft Sentinel using Kusto Query Language (KQL) | SC-200

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/72

encourage image

There's no tags or description

Looks like no tags are added yet.

73 Terms

1
New cards

KQL query (what it does)

Read-only. Returns results, never changes data.

2
New cards

Pipe ( | )

Passes results to the next operator. Left side runs first, then flows right.

3
New cards

Tabular expression statement

Table in, table out. The most common KQL statement.

4
New cards

Common Sentinel tables (module)

SecurityEvent = Windows security events. SecurityAlert = alerts.

5
New cards

KQL case sensitivity

Case-sensitive. Operators must be lowercase (let, where, search). Table and column names must match exactly.

6
New cards

search operator

Finds a term across ALL tables and columns. Fast to write, slow to run. Example: search "new"

7
New cards

search in (Table, App*)

Searches only the tables listed. App* = every table starting with App. Example: search in (SecurityEvent, App*) "new"

8
New cards

where operator

Filters rows to only the ones that match a condition. Example: | where EventID == 4624

9
New cards

ago()

Time back from now. Example: where TimeGenerated > ago(1h). Units: d, h, m, s (1h, not 1hr).

10
New cards

Combining filters

Use and / or on one line, OR stack several where lines (easier to read).

11
New cards

in operator

Matches any value in a list. Example: where EventID in (4624, 4625)

12
New cards

EventID 4624

Successful logon.

13
New cards

EventID 4625

Failed logon.

14
New cards

EventID 4634

Logoff.

15
New cards

EventID 4688

New process created.

16
New cards

EventID 4672

Privileged (admin-level) logon: special privileges assigned.

17
New cards

== (double equals)

Equals, case-SENSITIVE. "User" == "user" → false

18
New cards

=~ (equals tilde)

Equals, case-INSENSITIVE. "User" =~ "user" → true. Memory: ~ = "about the same"

19
New cards

!= vs !~

!= not equal (case-sensitive). !~ not equal (case-insensitive).

20
New cards

let statement

Creates a reusable variable. Ends with ; Example: let timeOffset = 1h;

21
New cards

let with a dataset

Stores a whole query result to reuse by name. Example: let LowActivity = SecurityEvent | summarize cnt=count() by Account | where cnt < 1000;

22
New cards

Time window with let

Between 2h ago and 1h ago: where TimeGenerated > ago(timeOffset*2) and TimeGenerated < ago(timeOffset)

23
New cards

extend operator

Adds a NEW calculated column. Keeps all existing columns. Example: | extend StartDir = substring(…)

24
New cards

order by / sort by

Sorts rows. asc = low to high, desc = high to low. Default = desc.

25
New cards

project

Shows only the columns you pick. Can rename or add computed columns. Example: | project Computer, Account

26
New cards

project-away

Removes the listed columns. Keeps the rest. Memory: AWAY = throw away.

27
New cards

project-keep

Keeps only the listed columns. Drops the rest.

28
New cards

project-rename

Renames a column. Example: | project-rename NewName = OldName

29
New cards

project-reorder

Changes the column order.

30
New cards

summarize operator

Groups rows and calculates totals. Example: | summarize count() by Account

31
New cards

count()

Number of rows per group.

32
New cards

countif()

Number of rows per group that meet a condition.

33
New cards

dcount()

Number of UNIQUE values (an estimate). Memory: d = distinct.

34
New cards

avg() / sum() / max() / min()

Average / total / highest / lowest per group. Each has an -if version (avgif, sumif…).

35
New cards

Password spray pattern (module)

Invalid password sign-ins → dcount(AppDisplayName) by UserPrincipalName, IPAddress. One IP failing across many apps = spray.

36
New cards

arg_max(TimeGenerated, *)

Returns the MOST RECENT full row per group. Memory: max = latest.

37
New cards

arg_min(TimeGenerated, *)

Returns the EARLIEST full row per group. Memory: min = first.

38
New cards

make_list()

Puts all values in one array per group. Keeps duplicates. Memory: List = Lots.

39
New cards

make_set()

Puts unique values in one array per group. No duplicates. Memory: Set = Single copy.

40
New cards

render operator

Turns results into a chart. Goes LAST, after summarize. Example: | render barchart

41
New cards

render chart types

areachart, barchart, columnchart, piechart, scatterchart, timechart

42
New cards

bin()

Groups time into buckets. Example: summarize count() by bin(TimeGenerated, 1m) | render timechart

43
New cards

union operator

Stacks ROWS from 2+ tables into one result. Example: SecurityEvent | union SigninLogs

44
New cards

union kind=outer vs kind=inner

outer (default) = keep all columns. inner = keep only columns found in every table.

45
New cards

union withsource=

Adds a column showing which table each row came from.

46
New cards

union then summarize count()

SecurityEvent | union SigninLogs | summarize count() → ONE row: total of both tables.

47
New cards

union with summarize in ( )

SecurityEvent | union (SigninLogs | summarize count()) → all SecurityEvent rows + ONE row with the SigninLogs count.

48
New cards

union App* | summarize count() by Type

Row count per table for every table starting with App. Type = table name.

49
New cards

join operator

Adds COLUMNS from a second table where a key matches. Example: T1 | join kind=inner (T2) on Account

50
New cards

union vs join

union = stacks ROWS (on top). join = adds COLUMNS (side by side on a key).

51
New cards

Default join kind

innerunique: removes duplicate keys on the LEFT, then inner join. Write kind=inner to keep every match.

52
New cards

join kind=inner

Only rows that match in BOTH tables.

53
New cards

join kind=leftouter

All LEFT rows + matching right rows. No match = empty right columns. (rightouter = the reverse)

54
New cards

join kind=fullouter

All rows from BOTH tables, matched where possible.

55
New cards

join kind=leftanti

LEFT rows with NO match on the right. Memory: anti = against / missing.

56
New cards

join kind=leftsemi

LEFT rows that DO match. Only left columns returned. Memory: semi = half (left side only).

57
New cards

$left / $right

Use when key names differ. Example: on $left.UserName == $right.Account

58
New cards

join best practice

Filter first. Put the SMALLER table on the left.

59
New cards

extract()

Pulls text out with regex. Format: extract(regex, group, text). Group 1 = inside first ( ), group 0 = whole match.

60
New cards

extract example

extract("x=([0-9.]+)", 1, "hello x=45.6|wo") → "45.6"

61
New cards

tolower()

Converts text to lowercase so case doesn't matter.

62
New cards

parse operator

Splits text with a fixed pattern into several columns. * = skip text. Example: parse EventText with * "resourceName=" resourceName "," *

63
New cards

extract vs parse

extract = regex, one value. parse = fixed pattern, many columns.

64
New cards

Dot notation (dynamic column)

Reads a field inside a dynamic column. Example: DeviceDetail.operatingSystem

65
New cards

parse_json()

Turns a JSON text string into an object you can read fields from.

66
New cards

Array index [0]

Picks the FIRST item in a JSON array. Example: AuthDetails[0].authenticationMethod = method of the first entry.

67
New cards

Bracket notation ["field"]

Another way to read a JSON field. AuthDetails[0]["authenticationMethod"] = AuthDetails[0].authenticationMethod

68
New cards

externaldata operator

Pulls data from outside storage (e.g. Azure Blob with a SAS token) into the query.

69
New cards

KQL function (saved query)

Save a query with a name (e.g. PrivLogins) and call it like a table. Used to build parsers.

70
New cards

has vs contains

has = whole word, faster. contains = any part of text, slower. Prefer has.

71
New cards

Where to write KQL

Microsoft Sentinel > Logs. Defender portal > Advanced hunting.

72
New cards

_CL table suffix

Custom log table. Example: SecurityEvent_CL

73
New cards

Custom column suffixes

_s = string, _d = number, _b = boolean, _t = datetime. Example: EventID_s