Writing rules

Create query, sequence and correlation rules in the editor, with test events that prove they fire.

The editor

Detections › New rule opens the editor. A rule has:

FieldMeaning
Name and descriptionWhat the rule catches, in the language an analyst on shift will read at 03:00.
SeverityCritical, high, medium or low. Sets the SLA clock and the queue ordering.
Data sourcesWhich catalog sources the rule needs. Shown as a warning when a deployment lacks them.
ATT&CKTactic and technique identifiers. Feed the coverage matrix.
ShapeQuery, sequence or correlation.
Query, or stagesThe query grammar from the Logs page, one per stage for the other shapes.
EntityThe field alerts are grouped by: host.name, user.name, source.ip.
Threshold and windowFor count rules: at least N matches within the window.
Cadence and lookbackHow often the rule runs and how far back it looks.
PlaybookThe playbook to run on each alert, if any.
TagsFree tags from the tag vocabulary.

Query rules

A query rule is the Logs grammar plus grouping:

text
event.module:sysmon event.code:1
process.command_line:*-enc* process.executable:*\powershell.exe

with entity host.name, threshold 1, window 10 minutes. Test it against the store with Preview, which runs the query over the lookback window and shows the events that would match, grouped by entity.

Sequence rules

Stages are ordered. Each stage has its own query; all stages must match the same entity value within the window, in order:

  1. event.type:logon_failed at least 10 times
  2. event.type:logon_success
  3. event.type:service_installed

with entity user.name and a window of 30 minutes.

Correlation rules

The same stages, matched in any order. Useful when sources arrive with different delays.

Test events

Attach test events to the rule: JSON documents that should fire it. Run test injects them into a scratch scope and shows whether an alert would be produced. Rules in the content pack all ship with test events; rules you write should too, because the efficacy report uses them to prove the rule still works after an upgrade.

Enabling

New rules start disabled. Enable them from the rule page or in bulk from the list. Enabling is audited.

Style

  • One behaviour per rule. Rules that catch three things produce alerts nobody can name.
  • Name the entity that should be blamed, not the one that is convenient.
  • Set the severity for what the match means, not for how rare it is.
  • Write the description for the person who will read the alert, including what to check first.