Skip to content

Commit 16b79cd

Browse files
authored
Merge pull request #178244 from batamig/ingestion-delay
Ingestion-delay
2 parents ed435f3 + 0237f63 commit 16b79cd

15 files changed

+110
-3
lines changed

articles/sentinel/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@
200200
href: work-with-anomaly-rules.md
201201
- name: Manage template versions for analytics rules
202202
href: manage-analytics-rule-templates.md
203+
- name: Handle ingestion delay in analytics rules
204+
href: ingestion-delay.md
203205
- name: Get fine-tuning recommendations
204206
href: detection-tuning.md
205207
- name: Enable User and Entity Behavior Analytics (UEBA)

articles/sentinel/audit-sentinel-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Use Microsoft Sentinel's own features to monitor events and actions that occur w
229229

230230
For more information, see [Commonly used Microsoft Sentinel workbooks](top-workbooks.md).
231231

232-
- **Watch for ingestion delay**. If you have concerns about ingestion delay, [set a variable in an analytics rule](https://techcommunity.microsoft.com/t5/azure-sentinel/handling-ingestion-delay-in-azure-sentinel-scheduled-alert-rules/ba-p/2052851) to represent the delay.
232+
- **Watch for ingestion delay**. If you have concerns about ingestion delay, [set a variable in an analytics rule](ingestion-delay.md) to represent the delay.
233233

234234
For example, the following analytics rule can help to ensure that results don't include duplicates, and that logs aren't missed when running the rules:
235235

articles/sentinel/detect-threats-custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ In the **Set rule logic** tab, you can either write a query directly in the **Ru
121121
>
122122
> To account for **latency** that may occur between an event's generation at the source and its ingestion into Microsoft Sentinel, and to ensure complete coverage without data duplication, Microsoft Sentinel runs scheduled analytics rules on a **five-minute delay** from their scheduled time.
123123
>
124-
> For a detailed technical explanation of why this delay is necessary and how it solves this problem, see Ron Marsiano's excellent blog post on the subject, "[Handling ingestion delay in Microsoft Sentinel scheduled alert rules](https://techcommunity.microsoft.com/t5/azure-sentinel/handling-ingestion-delay-in-azure-sentinel-scheduled-alert-rules/ba-p/2052851)".
124+
> For more information, see [Handle ingestion delay in scheduled analytics rules](ingestion-delay.md).
125125
126126
- Use the **Alert threshold** section to define the sensitivity level of the rule. For example, set **Generate alert when number of query results** to **Is greater than** and enter the number 1000 if you want the rule to generate an alert only if the query returns more than 1000 results each time it runs. This is a required field, so if you don’t want to set a threshold – that is, if you want your alert to register every event – enter 0 in the number field.
127127

articles/sentinel/ingestion-delay.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: Handle ingestion delay in Microsoft Sentinel | Microsoft Docs
3+
description: Handle ingestion delay in Microsoft Sentinel scheduled analytics rules.
4+
services: sentinel
5+
documentationcenter: na
6+
author: batamig
7+
manager: rkarlin
8+
editor: ''
9+
10+
ms.service: azure-sentinel
11+
ms.subservice: azure-sentinel
12+
ms.devlang: na
13+
ms.topic: how-to
14+
ms.tgt_pltfrm: na
15+
ms.workload: na
16+
ms.date: 04/25/2021
17+
ms.author: bagol
18+
19+
---
20+
21+
# Handle ingestion delay in scheduled analytics rules
22+
23+
While Microsoft Sentinel can ingest data from [various sources](connect-data-sources.md), ingestion time for each data source may differ in different circumstances.
24+
25+
This article describes how to ingestion delay might impact your scheduled analytics rules and how you can fix them to cover these gaps.
26+
27+
## Why delay is significant
28+
29+
For example, you might write a custom detection rule, setting the **Run query every** and **Lookup data from the last** fields to have the rule run every five minutes, looking up data from those last five minutes:
30+
31+
:::image type="content" source="media/ingestion-delay/create-rule.png" alt-text="Screenshot showing the Analytics Rule Wizard - Create new rule window." border="false":::
32+
33+
The **Lookup data from the last** field defines a setting known as a *look-back* period. Ideally, when there's no delay, this detection misses no events, as shown in the following diagram:
34+
35+
:::image type="content" source="media/ingestion-delay/look-back.png" alt-text="Diagram showing a five-minute look-back window." border="false":::
36+
37+
The event arrives as it's generated, and is included in the *lookback* period.
38+
39+
Now, assume there's some delay for your data source. For this example, let's say the event was *ingested* two minutes after it was *generated*. The delay is two minutes:
40+
41+
:::image type="content" source="media/ingestion-delay/look-back-delay.png" alt-text="Diagram showing five-minute look back windows with a delay of two minutes." border="false":::
42+
43+
The event is generated within the first look-back period, but isn't ingested in your Microsoft Sentinel workspace on the first run. The next time the scheduled query runs, it ingests the event, but the time-generated filter removes the event because it happened more than five minutes ago. In this case, **the rule does not fire an alert**.
44+
45+
## How to handle delay
46+
47+
To solve the issue, you need to know the delay for your data type. For this example, you already know the delay is two minutes.
48+
49+
For your own data, you can understand delay using the Kusto `ingestion_time()` function, and calculating the difference between **TimeGenerated** and the ingestion time. For more information, see [Calculate ingestion delay](#calculate-ingestion-delay).
50+
51+
After determining the delay, you can address the problem as follows:
52+
53+
- **Increase the look-back period**. Basic intuition tells you that increasing the look-back period size will help. Since your look-back period is five minutes and your delay is two minutes, setting the look-back period to *seven* minutes will help address this problem. For example, in your rule settings:
54+
55+
:::image type="content" source="media/ingestion-delay/set-look-back.png" alt-text="Screenshot that shows setting the look-back window to seven minutes.":::
56+
57+
The following diagram shows how the look-pack period now contains the missed event:
58+
59+
:::image type="content" source="media/ingestion-delay/longer-look-back.png" alt-text="Diagram that shows seven-minute look back windows with a delay of two minutes." border="false":::
60+
61+
- **Handle duplication**. Only increasing the look-back period can create duplication, because the look-back windows now overlap. For example, a different event may look as shown in the following diagram:
62+
63+
:::image type="content" source="media/ingestion-delay/overlapping-look-back.png" alt-text="Diagram showing how overlapping look-back windows create duplication." border="false":::
64+
65+
Since the event **TimeGenerated** value is found in both look-back periods, the event fires two alerts. You need to find a way to solve the duplication.
66+
67+
- **Associate the event to a specific look-back period**. In the first example, you missed events because your data wasn't ingested when the scheduled query ran. You extended the look-back to include the event, but this caused duplication. You have to associate the event to the window you extended to contain it.
68+
69+
Do this by setting `ingestion_time() > ago(5m)`, instead of the original rule `look-back = 5m`. This setting associates the event to the first look-back window. For example:
70+
71+
:::image type="content" source="media/ingestion-delay/ago-restriction.png" alt-text="Diagram showing how setting the ago restriction avoids duplication." border="false":::
72+
73+
The ingestion time restriction now trims the extra two minutes you added to the look-back period. And for the first example, the second run look-back period now captures the event:
74+
75+
:::image type="content" source="media/ingestion-delay/ago-restriction-capture.png" alt-text="Diagram showing how setting the ago restriction captures the event." border="false":::
76+
77+
The following sample query summarizes the solution for solving ingestion delay issues:
78+
79+
```kusto
80+
let ingestion_delay = 2min;
81+
let rule_look_back = 5min;
82+
CommonSecurityLog
83+
| where TimeGenerated >= ago(ingestion_delay + rule_look_back)
84+
| where ingestion_time() > ago(rule_look_back)
85+
```
86+
87+
88+
## Calculate ingestion delay
89+
90+
By default, Microsoft Sentinel scheduled alert rules are configured to have a 5-minute look-back period. However, each data source may have its own, individual ingestion delay. When joining multiple data types, you must understand the different delays for each data type in order to configure the look-back period correctly.
91+
92+
The **Workspace Usage Report**, provided in Microsoft Sentinel out-of-the-box, includes a dashboard that shows latency and delays for the different data types flowing into your workspace.
93+
94+
For example:
95+
96+
:::image type="content" source="media/ingestion-delay/end-to-end-latency.png" alt-text="Screenshot of the Workspace Usage Report showing End to End Latency by table":::
97+
98+
99+
## Next steps
100+
101+
For more information, see:
102+
103+
- [Create custom analytics rules to detect threats](detect-threats-custom.md)
104+
- [Customize alert details in Azure Sentinel](customize-alert-details.md)
105+
- [Manage template versions for your scheduled analytics rules in Azure Sentinel](manage-analytics-rule-templates.md)
94.6 KB
Loading
93.6 KB
Loading
50.8 KB
Loading
34.1 KB
Loading
186 KB
Loading
82.1 KB
Loading

0 commit comments

Comments
 (0)