Near-Real-Time NRT Rules

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 9 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Threat Detection with Microsoft Sentinel: Mastering Near-Real-Time (NRT) Rules

Introduction: The Need for Speed in Modern Security Operations

In the landscape of modern cybersecurity, time is the most valuable currency. When an adversary gains unauthorized access to your environment, every minute that passes before detection increases the likelihood of data exfiltration, lateral movement, or ransomware deployment. Traditional security information and event management (SIEM) systems have historically relied on scheduled queries that run every hour or every few hours. While these are sufficient for long-term trend analysis or compliance reporting, they are fundamentally inadequate for stopping an active, fast-moving threat.

This is where Near-Real-Time (NRT) rules in Microsoft Sentinel change the game. NRT rules are a specialized type of analytic rule designed to bridge the gap between heavy, complex scheduled hunting and the immediate response required for critical security incidents. By executing at a much higher frequency—typically every minute—NRT rules provide security operations center (SOC) analysts with the visibility they need to intervene while an attack is still in its infancy.

Understanding how to build, tune, and manage NRT rules is a fundamental skill for any security engineer working with Sentinel. This lesson will guide you through the technical architecture of NRT rules, how to write efficient Kusto Query Language (KQL) for high-frequency execution, and how to balance the need for speed with the reality of alert fatigue.


Not read yet

Understanding the Architecture of NRT Rules

To appreciate why NRT rules are effective, we must look at how they differ from standard scheduled analytics. A standard scheduled rule in Sentinel pulls data from the workspace, runs a query over a lookback period, and then evaluates the results. This process is optimized for resource efficiency, allowing for complex joins, aggregations, and data correlation across massive datasets. However, because of the computational overhead, these rules are usually limited to running once per hour or once per day.

NRT rules take a different approach. They are designed to run every minute, querying the last minute of data. This architectural constraint necessitates a shift in how you write your queries. Because the rule runs so frequently, it does not have the luxury of performing massive joins across multi-gigabyte tables. Instead, NRT rules are best suited for high-fidelity, event-driven detection where a single log entry or a small burst of activity constitutes an actionable security event.

Callout: The Trade-off Between Depth and Speed When choosing between a Scheduled Rule and an NRT Rule, you are essentially choosing between "context" and "latency." Scheduled rules allow you to perform complex correlation across multiple data sources, providing a richer context for the alert. NRT rules provide the fastest possible notification for specific, high-risk events, but they lack the ability to look back over long time windows or correlate data across disparate datasets.

Key Characteristics of NRT Rules

  • Execution Frequency: Fixed at one minute.
  • Lookback Period: Restricted to the last minute of data ingestion.
  • Resource Constraints: They must be highly optimized KQL queries because they run continuously.
  • Use Case Suitability: Ideal for immediate threats like credential stuffing, brute force attacks, or known malicious IP connections.

Not read yet

When to Use NRT Rules: Practical Scenarios

You should not convert every detection rule to an NRT format. Doing so would lead to significant performance degradation and, more importantly, an overwhelming amount of noise for your analysts. NRT rules should be reserved for scenarios where immediate action is required to prevent damage.

1. Brute Force and Credential Stuffing

If you detect multiple failed sign-ins followed by a single successful sign-in from the same IP address, you want to know about it immediately. An NRT rule can watch for these specific patterns in the SigninLogs table. If an attacker is attempting to guess passwords, waiting an hour to be alerted is an eternity; the account will likely be compromised long before the next scheduled rule runs.

2. Unauthorized Configuration Changes

Detecting changes to critical security controls, such as disabling a firewall, modifying an Azure Policy, or adding a new global administrator to your tenant, requires immediate attention. These are high-fidelity events where a single log entry is often enough to warrant an incident. NRT rules excel here because they catch the change the moment it is written to the log store.

3. Known Malicious Indicators (IOCs)

If you receive a threat intelligence feed containing the latest IP addresses or file hashes used by a specific ransomware group, you can create an NRT rule to monitor your network traffic logs. As soon as a connection is initiated to one of those IPs, the rule fires, allowing the SOC to isolate the affected host within seconds.

Note: NRT rules are not intended for trend-based detection. If your detection logic requires calculating a baseline (such as "alert if sign-ins are 3 standard deviations above the mean"), you must use scheduled analytics. NRT rules rely on absolute thresholds rather than statistical deviations.


Not read yet

Step-by-Step: Creating an NRT Rule in Sentinel

Creating an NRT rule is a straightforward process, but the complexity lies in the KQL query design. Follow these steps to deploy your first rule.

Step 1: Navigate to the Analytics Blade

In your Microsoft Sentinel workspace, navigate to the Configuration section and select Analytics. Click on the Create button and select NRT rule (preview).

Step 2: Define the Rule Name and Description

Give your rule a clear, descriptive name. Use a naming convention that indicates the type of threat and the severity. For example: NRT - Critical Account Modification Detected. In the description, clearly state what the rule does and, crucially, what the analyst should do when they receive the alert.

Step 3: Write the KQL Query

This is the most critical step. Your query must be fast. Avoid using join or union operations if possible, as these are resource-intensive. Focus on filtering the data as early as possible in the query pipeline.

// Example: Detecting a new Global Administrator added
AuditLogs
| where OperationName == "Add member to role"
| extend Target = tostring(TargetResources[0].userPrincipalName)
| extend Actor = tostring(InitiatedBy.user.userPrincipalName)
| where TargetResources[0].modifiedProperties[1].newValue contains "Global Administrator"
| project TimeGenerated, OperationName, Actor, Target, Result

Step 4: Configure Alert Logic

Since NRT rules have a fixed execution frequency, you do not need to configure the "run query every" interval. However, you must configure the "Alert threshold." For most NRT rules, you will set this to "Greater than 0," meaning that if the query returns even one result, an incident is generated.

Step 5: Incident Settings and Automation

Configure how Sentinel should group these alerts. If you are monitoring a high-volume event, you might want to enable alert grouping to prevent the creation of dozens of individual incidents for the same underlying issue. You can also attach an automation rule or a playbook to the analytic rule, allowing for immediate remediation, such as disabling a compromised user account automatically.


Not read yet

Writing High-Performance KQL for NRT Rules

The primary constraint of NRT rules is the execution time. If your query takes too long to run, the system will eventually throttle or fail the execution. To keep your queries performant, follow these best practices.

1. Filter by Time Early

Always use the TimeGenerated column at the beginning of your query. Even though NRT rules look at the last minute of data, explicitly filtering helps the query engine optimize the execution plan.

// Good: Filtering immediately
SigninLogs
| where TimeGenerated > ago(1m)
| where ResultType == 0

2. Avoid Heavy Joins

Joins are the enemy of speed. If you need to correlate data, try to use lookup if the dataset is small, or better yet, structure your data ingestion so that the necessary information is already present in the primary table. If you absolutely must use a join, ensure that you are joining against a small, pre-filtered set of data.

3. Use Specific Columns

Don't use project *. Instead, explicitly list the columns you need. This reduces the memory footprint of the query and speeds up data processing.

4. Use has and in Operators

When searching for strings or lists, use the has operator instead of contains. The has operator looks for whole terms and is significantly faster because it utilizes the underlying index of the table.

// Faster than 'contains'
SecurityEvent
| where EventID has "4624"

Not read yet

Comparison Table: Scheduled vs. NRT Rules

Feature Scheduled Rules NRT Rules
Execution Frequency Configurable (e.g., 1hr, 4hr, 24hr) Fixed (1 minute)
Lookback Window Configurable Fixed (1 minute)
Complexity High (Supports joins, ML, aggregations) Low (Simple filtering, high-fidelity)
Primary Use Case Long-term hunting, threat correlation Immediate response, high-risk events
Resource Usage Moderate to High Low (per execution)

Best Practices and Industry Standards

To ensure your SOC remains effective and focused, you must manage your NRT rule library with discipline. An unmanaged collection of NRT rules will quickly lead to burnout.

1. The "High-Fidelity" Principle

Only promote a rule to NRT if it has a proven track record of low false-positive rates. If a rule triggers every minute and 90% of those triggers are benign, your analysts will stop trusting the alerts. Before making a rule NRT, run it as a scheduled rule for several weeks to validate its precision.

2. Document the Response

Every NRT rule should be accompanied by a clear, step-by-step investigation guide (often called a "playbook" or "runbook"). When an analyst receives an NRT alert, they should not have to guess what to do next. The description field in the Sentinel rule should link directly to internal documentation or an automated response workflow.

3. Monitor Rule Performance

Microsoft Sentinel provides logs for the analytic rules themselves. Periodically check the SentinelHealth or AzureActivity logs to see if any of your NRT rules are consistently failing or taking a long time to execute. If a rule is consistently hitting the resource limits, it is a sign that it needs to be optimized or converted back to a scheduled rule.

4. Avoid Over-Alerting

Use grouping. If you have an NRT rule looking for brute force attacks, group the resulting alerts by the target user or the source IP. This ensures that the analyst sees one incident with multiple related events, rather than one hundred separate incidents that all represent the same attack.

Warning: Do not rely on NRT rules for regulatory compliance reporting. Because NRT rules are designed for real-time alerting, they are not suitable for generating historical reports or audit logs. Always use scheduled queries for those types of tasks to ensure data consistency.


Not read yet

Common Pitfalls and How to Avoid Them

Even experienced security engineers fall into common traps when implementing NRT rules. Recognizing these issues early can save you significant time.

Trap 1: The "Everything is Important" Mindset

It is tempting to make every detection an NRT rule because you want to be as secure as possible. However, security is a resource-constrained environment. If you alert on everything, you effectively alert on nothing. Focus your NRT rules on "Crown Jewel" assets—servers, accounts, and data stores that, if compromised, would cause existential damage to the organization.

Trap 2: Neglecting Schema Changes

Microsoft frequently updates the schemas for logs in Azure. An NRT rule that works perfectly today might break if a field name changes or if a log format is updated. Build a process to periodically review your rules, especially after major system updates or changes in your environment.

Trap 3: Ignoring Data Latency

Even though NRT rules run every minute, data ingestion is not always instantaneous. Sometimes, logs take a few minutes to arrive in the Sentinel workspace. If your NRT rule assumes that data is available the exact second an event occurs, you might miss alerts. Always account for a slight ingestion delay in your logic, or accept that NRT rules catch events "as soon as they hit the workspace" rather than "as soon as they happen on the endpoint."

Trap 4: Lack of Correlation

Because NRT rules are limited to a one-minute window, they struggle to correlate events that happen slightly apart. For example, if an attacker performs a password spray over a five-minute period, an NRT rule looking only at the last minute might miss the pattern entirely. In such cases, use a hybrid approach: an NRT rule for the most critical events, and a scheduled rule to catch the broader, slower attack pattern.


Not read yet

Advanced Scenarios: Combining NRT and Automation

The true power of Sentinel is realized when you combine NRT detection with automated response. Imagine an NRT rule that detects a user account suddenly logging in from a country where the organization has no business presence.

  1. Detection: The NRT rule triggers on the SigninLogs entry.
  2. Incident Creation: An incident is automatically created in Sentinel.
  3. Automation: A logic app is triggered that immediately disables the user account in Microsoft Entra ID (formerly Azure AD) and invalidates all existing refresh tokens.
  4. Notification: The security team is notified via Microsoft Teams or email that the account was compromised and has been secured.

This entire sequence occurs in less than a minute. This level of automation is only possible because the NRT rule provided the "trigger" immediately. Without the NRT rule, the attacker would have had an hour or more to move laterally before the scheduled detection caught the anomaly.

Implementing the Automation Logic

To set this up, you need an Automation Rule in Sentinel.

  • Trigger: When an incident is created.
  • Condition: The incident is generated by your specific NRT rule.
  • Action: Run a Playbook (Logic App).

Inside your Logic App, use the "Microsoft Entra ID" connector to perform the account disablement. Always ensure that your automation has a "human-in-the-loop" option for high-impact actions if you are not 100% confident in the accuracy of the detection. For example, you might choose to automatically block the account but send a notification to the SOC manager for approval before taking further, more disruptive actions.


Not read yet

Key Takeaways for Success

Mastering NRT rules is about balancing the immediate need for detection with the technical realities of system performance and analyst workload. Keep these core principles in mind as you build your security posture:

  1. Prioritize High-Fidelity: Only use NRT for events that have a very low false-positive rate. If an event is noisy, keep it in a scheduled rule.
  2. Optimize KQL for Speed: Use TimeGenerated filters, avoid heavy joins, and use efficient operators like has to ensure your queries run within the one-minute window.
  3. Group Your Alerts: Use incident grouping to prevent alert fatigue. An analyst should investigate a "campaign" of events, not hundreds of individual, disconnected alerts.
  4. Define Clear Responses: Every NRT rule must have a corresponding investigation guide or automated playbook. An alert without a response plan is just noise.
  5. Monitor Performance: Regularly check the execution health of your rules. If a rule is slow or failing, optimize it immediately to prevent gaps in your security coverage.
  6. Use a Hybrid Strategy: NRT rules are one tool in a larger toolkit. Combine them with scheduled rules, threat intelligence, and user behavior analytics to create a comprehensive defense-in-depth strategy.
  7. Test Before You Deploy: Always run a new rule as a "test" (without triggering incidents) to ensure it performs as expected and does not generate unexpected volumes of data.

By following these guidelines, you will move beyond simple alert management and toward a proactive, high-velocity security operations model. Microsoft Sentinel's NRT capabilities are a powerful asset, but their effectiveness depends entirely on the design, discipline, and documentation you bring to the table as a security practitioner. Start small, validate your detections, and scale your automation as your confidence in your rules grows.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.