Detection as Code

Detection rule

A detection rule is a stored query or logic that runs over security data and raises an alert when it matches. It has a language, a schedule or trigger, a severity and usually ATT&CK tags. Products call them analytics rules, correlation searches, detections or rules, but the object is the same.

What Detection rule means here

A rule has three parts that matter for engineering: the logic, the metadata around it and the place it runs. The logic is written in the platform's language. The metadata includes severity, mapping and status. The place decides which data and fields the rule can see.

Because a rule depends on field names and sources, it can stop working when the data changes. That is the root of most rule health problems.

Example of Detection rule in Elastic Security documentation

In Elastic's detection-rules repository each rule is a TOML file in the rules directory, and the README says hand-writing the TOML is possible but not recommended. github.com read 2026-11-03

Terms related to Detection rule

The matrix scores platforms on whether they document these ideas: see the matrix and the full glossary.