Commit 5a5a2d0
authored
[Alerting] Preserve rule type payload across delayed-to-active graduation (elastic#266012)
## Summary
Resolves elastic#259886. Architectural alternative to elastic#265588.
When a delayed alert is reactivated by `delayRecoveredFlappingAlerts`
(flap-hold) and crosses `alertDelay` on a run where the executor does
**not** report it, the alert builder used to dispatch to `buildNewAlert`
with an empty payload — producing an active AAD doc with blank rule type
fields (e.g. `kibana.alert.reason`).
Rather than skip the graduation in that case, this PR makes the
framework own the `delayed -> active` transition explicitly so the
resulting active doc is always complete.
### Fix (code)
- **`buildDelayedAlert`** now stores the full executor payload on the
delayed AAD doc. Previously the delayed doc only carried framework
fields. Persisting the rule type payload turns each delayed doc into a
usable predecessor.
- **`buildGraduatedAlert`** is a new builder dedicated to `delayed ->
active` transitions. It deep-merges the predecessor delayed doc with the
current run's payload (per-field precedence: current wins, predecessor
fills gaps), sets `event.action: 'open'` and `kibana.alert.status:
active`, and treats the alert as user-visible for the first time
(`severity_improving: false`, no `previous_action_group`).
- **`AlertBuilder.buildActiveAlerts`** now branches on `trackedActive`
vs `trackedDelayed` to dispatch to ongoing / graduated / new
respectively, instead of the previous status check on a single tracked
alert.
The per-field merge means:
| Run shape on graduation | `cleanedPayload[K]` | Resulting field |
| --- | --- | --- |
| Executor reports `K` | present | fresh value (predecessor shadowed) |
| Flap-hold reactivation, no executor report | absent | predecessor's
value preserved |
| Partial report (some `K` reported) | present for some | executor where
present, predecessor where absent |
This matches the long-standing semantics of `buildOngoingAlert`, just
sourced from the delayed predecessor instead of an active one.
How to reproduce the issue (on the 6th execution we see an alert without
context):
Run | pattern | flappingHistory | active | recovered | activeCount |
pending recovered | flapping | AAD status
-- | -- | -- | -- | -- | -- | -- | -- | --
1 | a | T | x | | 1 | 0 | FALSE | delayed
2 | a | T,F | x | | 2 | 0 | FALSE | active
3 | - | T,F,T | | x | 0 | - | FALSE | recovered
4 | - | T,F,T,F | | x | 0 | - | FALSE | recovered
5 | a | T,F,T,F,T | x | | 1 | 0 | FALSE | delayed
6 | - | T,F,T,F,T,T | x | | 2 | 1 | TRUE | active1 parent f737970 commit 5a5a2d0
9 files changed
Lines changed: 940 additions & 39 deletions
File tree
- x-pack/platform
- test/alerting_api_integration
- common/plugins/alerts/server
- spaces_only/tests/alerting/group4/alerts_as_data
Lines changed: 34 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
188 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
193 | 197 | | |
194 | 198 | | |
195 | | - | |
| 199 | + | |
196 | 200 | | |
197 | 201 | | |
198 | | - | |
| 202 | + | |
199 | 203 | | |
200 | 204 | | |
201 | 205 | | |
| |||
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
210 | 234 | | |
211 | 235 | | |
212 | 236 | | |
| |||
277 | 301 | | |
278 | 302 | | |
279 | 303 | | |
280 | | - | |
281 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
282 | 311 | | |
283 | 312 | | |
284 | 313 | | |
| |||
Lines changed: 130 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
11 | 23 | | |
| 24 | + | |
| 25 | + | |
12 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
13 | 31 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 32 | + | |
18 | 33 | | |
19 | 34 | | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
23 | 38 | | |
24 | | - | |
| 39 | + | |
25 | 40 | | |
26 | 41 | | |
27 | 42 | | |
| |||
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
34 | | - | |
35 | 49 | | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
39 | 58 | | |
40 | 59 | | |
41 | | - | |
42 | 60 | | |
| 61 | + | |
| 62 | + | |
43 | 63 | | |
44 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
45 | 120 | | |
46 | 121 | | |
47 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
48 | 169 | | |
0 commit comments