How to Write an Analytics Rule in Microsoft Sentinel

A good Analytics Rule in Microsoft Sentinel begins with the behavior to detect and the sources that can prove it. Then, write KQL that returns a clear investigative unit, define frequency and Lookback, map Entities, set Severity and MITRE, choose Grouping, and perform Test and Tuning. The goal of the rule is not to generate many Alerts, but to create Incidents that can be understood, verified, and acted upon.
It's easy to write a Query that returns rows. It's harder to turn it into a stable Detection. An Analytics Rule runs over time on changing data, generates Alerts, affects analyst workload, and sometimes triggers Automation. An error in defining a time window, Entity, or Threshold can create duplicates, misses, or an incorrect response.
Microsoft Sentinel supports several types of Analytics rules. Scheduled rules are the most common and are based on KQL that runs at intervals and examines a Lookback period. There are also NRT — Near Real-Time — and built-in templates or detections depending on the platform. This guide focuses on the Scheduled query rule, as it allows understanding all planning components.
The example is Password Spray in a lab environment. It is not intended for monitoring unauthorized individuals, and the Thresholds are not universal recommendations. They should be calibrated against the organization's Baseline, identity architecture, and VPN/Proxy.




