Detection Engineering: A Practitioner's Guide
What detection engineering is, the lifecycle from threat to maintained rule, detection-as-code, Sigma versus native queries, testing, detection health, the role, and the metrics that matter.
Last reviewed November 2026
Detection engineering is the practice of turning knowledge of attacker behavior into detection logic that reliably fires on your own data, and keeping that logic working as your environment changes.
Most definitions stop after the first half. They describe writing rules. The second half is where the work actually lives: a rule depends on a log source, a parser, a field name, a lookup table and a product version, and every one of those moves without telling you. In our own measurements across six SIEM platforms, nearly 3 in 10 deployed, enabled rules were broken, and a broken rule produces no alert, so nothing in the console tells you.
This guide is written for the people who do the work and the people who run those teams. It covers the lifecycle end to end, how to manage rules as code, when to write Sigma and when to write native queries, how to test, how to catch drift, what the job involves, and how to measure it.
Detection engineering vs. monitoring, hunting and threat intel
Detection engineering borrows from several neighboring disciplines, and the boundaries matter because they decide who owns what.
- Security monitoring consumes alerts. Detection engineering produces the logic that creates them.
- Threat hunting is a human searching for activity that no rule caught. A good hunt that finds something repeatable should end as a detection, so hunters are one of detection engineering's best sources of new work.
- Threat intelligence describes what adversaries do. Detection engineering decides which of those behaviors matter here, whether your telemetry can see them, and how to express that as logic.
- Content packs and vendor rules are starting material. Somebody still has to check that the fields they reference exist in your data, tune them for your environment and own them afterwards.
The output of detection engineering is a maintained detection: logic, documentation, tests, an owner, and evidence that it still works.
The detection engineering lifecycle
Every mature team runs some version of the same loop. The names vary; the stages do not.
- Threat. Work arrives from somewhere: a new advisory, a red team finding, a missed incident, a hunt, a gap in your coverage map, or an analyst asking why something did not alert. Write down the trigger. It is the first line of the detection's documentation and the reason anyone will care if it breaks.
- Research. Work out what the adversary actually does, at the level of observable behavior. "Credential dumping" is a category; "a process opens a handle to lsass.exe with read access from an unsigned binary" is a behavior. Note what must be true for the attack to succeed, what evidence it leaves, and which variations an attacker can choose between.
- Data check. Before writing a line of logic, confirm that the telemetry exists. Is the log source collected? Is it parsed? Are the fields you need populated, with the types you expect, on the hosts that matter? This stage is skipped more than any other, and it is the reason so many rules are dead on arrival.
- Write. Express the behavior as a query in your SIEM's language or in a portable format. Aim at the behavior rather than an indicator that the attacker can change in a minute: a file hash or a domain is cheap for them to rotate, and a technique is expensive.
- Tune. Run the logic over recent history and look at what it would have fired on. Separate benign enterprise activity (backup agents, admin tooling, deployment systems) from the behavior you want, and write exclusions that are as narrow as you can make them. Every exclusion is a place an attacker can hide, so document why each one exists.
- Validate. Prove that the rule fires on the behavior it targets and stays quiet on normal activity. That means a true positive test and a false positive check, covered in more detail below.
- Deploy. Ship the rule through review, with an owner, a severity, a response note for the analyst who receives it, and a way to roll it back.
- Maintain. Watch the rule in production. Track its alert volume and verdicts, re-validate its dependencies, and retire it when the threat or the asset it protects is gone.
The first seven stages are a project. The eighth never ends, and it is the reason detection engineering is a function rather than a one-time content push. On average, a new detection takes 121 days to author by hand, and the query itself is the smallest part of that work. That gap is why teams are now automating stages of the loop. Spectrum's detection engineering platform runs this same lifecycle, from threat research to a tuned and validated rule in your SIEM's language, with your team reviewing and approving each rule before it ships.
Detection-as-code
Detection-as-code means managing detections the way software teams manage code: in version control, changed through pull requests, tested automatically, and deployed by a pipeline instead of by hand in a console.
A typical setup looks like this:
- One rule per file in a repository, with the query alongside its metadata: description, ATT&CK technique, data sources required, severity, owner, false positive notes and a link to the research behind it.
- Pull request review for every change, so a second engineer sees every new rule and every new exclusion.
- Continuous integration that lints the rule, checks the metadata is complete, converts portable rules to the target language, and runs unit tests against sample events.
- Automated deployment to the SIEM through its API, so what is in the repository is what is running, and a bad change can be reverted with one commit.
The benefits are the familiar ones from software: history, review, reproducibility and rollback. A rule that has been silently edited in a console six times by four people is a rule nobody can reason about.
Detection-as-code has one important limit. Its tests run at commit time, against your assumptions about the data. They confirm that the rule is valid and that it matches a sample event you saved. They cannot tell you that, three months later, a vendor renamed the field the rule depends on. We cover that gap under detection health below, and in more depth in why detection-as-code won't catch a rule that stops firing.
Sigma vs. native query languages
Every SIEM has its own query language: SPL for Splunk, KQL for Microsoft Sentinel, ES|QL and EQL for Elastic, YARA-L for Google SecOps, CQL for CrowdStrike Falcon Next-Gen SIEM. Sigma is a vendor-neutral rule format that describes a log source and a set of field conditions, and converts into any of them through backends and field-mapping pipelines.
Write in Sigma when portability is the point. Sigma is the right format for sharing detections publicly, consuming community rules, running more than one SIEM, or planning a migration. It forces you to describe the behavior separately from any one product's syntax, which is a useful discipline in itself.
Write natively when the platform is the point. Native languages expose things Sigma cannot express, or expresses poorly: joins across data sources, stateful sequences, statistical baselines, data model acceleration in Splunk, watchlists and reference lists, and platform-specific performance tuning. A converted rule is also only as good as the field mapping it was converted with. If your normalization differs from the rule author's assumption, the output is valid syntax that matches nothing and reports no error.
In practice, most mature teams do both: they keep the knowledge portable and deploy native. Treat a converted Sigma rule as a draft, read the generated query, and test it on your data before trusting it.
There is also a layer above the query. A query is an implementation for one environment. The research behind it (what the behavior is, what evidence it leaves, which telemetry can see it, which detection strategies are possible) is the part that is expensive to rebuild. Our research team publishes that knowledge in an open format, described in Delta Tradecraft: portable detection knowledge, so the same research can produce a Sigma rule, a native query or an honest "not detectable here."
Testing and validating detections
A detection that has never been seen to fire is a hypothesis. Testing turns it into a control. There are four kinds of test worth running, and they answer different questions.
- Unit tests run a rule against stored events: at least one event that should match and several that should not. They catch logic errors and regressions when someone edits the rule. They belong in CI.
- Historical backtesting runs the rule over the last 30 to 90 days of real data. It tells you how many alerts the rule would have produced and what they look like, which is the input to tuning. It also tells you whether the fields the rule needs are present at all.
- Attack emulation reproduces the behavior in a test environment, with tools like Atomic Red Team or a purple team exercise, and checks that the alert arrives end to end, through collection, parsing, the rule and the alert queue. It is the only test that proves the whole chain works.
- Positive controls are scheduled, harmless events that should always trigger a specific detection. If the alert stops arriving, the rule or something underneath it has broken.
Validation has two sides and both matter. A rule that fires on everything has passed its true positive test and failed its job. Check false positive resistance with the same care as detection, because a noisy rule trains analysts to ignore it.
Detection health and drift
Detection drift is the gradual, silent divergence between what a rule assumes about your environment and what is actually there. It is the most underestimated problem in the discipline, because a broken rule and a quiet rule look identical: neither one fires.
Common causes, all taken from real customer environments:
- A log source stops forwarding after an agent upgrade or a network change.
- A vendor changes a schema, and a field moves, is renamed, or turns from a single value into an array.
- A field that used to arrive as a number starts arriving as a string, so every comparison stops evaluating correctly.
- A threat intel feed's API key expires, the lookup list drains to empty, and the rule evaluates to false on every run.
- A privacy change starts hashing usernames, and a rule keyed on usernames now sees hashes.
None of these throw an error. The way to catch them is to treat every detection as a chain of dependencies (log source, event type, fields, values, parsers, lookups, macros) and to check that chain against live data on a schedule. That check separates a dormant rule, which would fire if the behavior happened, from a dead one, which would not. We describe how to run that check, and what the verdicts look like, in detection health: knowing which of your rules would actually fire.
Detection health, the share of your deployed rules that would fire if their target behavior occurred today, is the single most useful number a detection team can report. Most teams cannot produce it.
What does a detection engineer do?
A detection engineer builds and maintains the logic that turns telemetry into alerts. Day to day, that means:
- triaging requests for new detections from threat intel, incident response, red teams and the SOC
- researching attacker techniques and the technologies they target
- working with data and platform teams to get the right logs collected and parsed
- writing and reviewing rules, tests and exclusions
- tuning noisy rules using verdicts from the analysts who receive the alerts
- investigating why a rule did not fire when it should have
- reporting coverage and health to leadership
The skills sit at an intersection: attacker tradecraft, log sources and how they are parsed, at least one SIEM query language well, software engineering habits (version control, testing, review), and enough statistics to reason about baselines and alert volume. The best detection engineers are good at saying "we cannot detect this with the data we have," and then explaining exactly what data would change the answer.
The role differs from a SOC analyst's, who investigates the alerts, and from a threat hunter's, who searches for what no rule caught. In smaller teams one person may do all three. As programs grow, detection engineering usually becomes its own function, because maintenance alone grows with every rule you ship.
Detection engineering metrics
Count of rules is the metric most teams report and the least useful. A thousand rules with a third of them broken is worse than six hundred that work. These measure the program instead:
- Detection health: the share of deployed rules that would fire on their target behavior today. The number that tells you whether the rest of the metrics can be trusted.
- Coverage of prioritized threats: of the behaviors that matter to your environment, how many have a validated, healthy detection. Measure against a prioritized list, not against every cell of an ATT&CK heatmap, which counts rules you own rather than threats you can see.
- Time to detection: how long from a new threat arriving to a validated rule in production. This is the speed of the whole lifecycle.
- Time to repair: how long a broken rule stays broken, from the moment it breaks (not the moment someone notices) to the fix.
- Alert precision per rule: the share of a rule's alerts that analysts close as true positives. Low precision is a tuning backlog.
- Alert volume per rule: a handful of rules usually produce most of the noise. Find them first.
- Data cost per detection: which log sources your detections actually read, and which you pay to ingest that no detection uses.
Report health and coverage to leadership. Use precision, volume and repair time to run the team.
Where to go next
Each part of this guide has its own deeper page in this series, listed alongside this guide. For the research side of the craft, start with Delta Tradecraft. For the maintenance side, read detection health and the Detection Debt Report.
Guides in this series
- Detection as Code: A Practical GuideHow to run detection as code in practice: the repository, the rule format, tests, the CI pipeline, deployment, drift, and the one failure mode commit-time tests cannot catch.
- Elastic Detection Rules: Types, Tuning and TestingHow Elastic Security detection rules work: the seven rule types, prebuilt rules and the detection-rules repository, scheduling and look-back, why rules go quiet, and how to test them.
- Sigma Rules: A Practitioner's GuideWhat Sigma rules are, how a rule is built, how pySigma converts it for your SIEM, where portability breaks, and how to test and review rules before you deploy them.
See what your environment is actually detecting
Spectrum maps your coverage, builds the detections you are missing, and keeps them working.