@@ -339,13 +339,17 @@ export class EndpointDocGenerator {
339339 percentNodesWithRelated ?: number ,
340340 percentChildrenTerminated ?: number
341341 ) {
342- const ancestry = this . createAlertEventAncestry ( alertAncestors ) ;
342+ const ancestry = this . createAlertEventAncestry (
343+ alertAncestors ,
344+ relatedEventsPerNode ,
345+ percentNodesWithRelated
346+ ) ;
343347 for ( let i = 0 ; i < ancestry . length ; i ++ ) {
344348 yield ancestry [ i ] ;
345349 }
346- // ancestry will always have at least 2 elements, and the second to last element will be the process associated with the alert
350+ // ancestry will always have at least 2 elements, and the last element will be the alert
347351 yield * this . descendantsTreeGenerator (
348- ancestry [ ancestry . length - 2 ] ,
352+ ancestry [ ancestry . length - 1 ] ,
349353 childGenerations ,
350354 maxChildrenPerNode ,
351355 relatedEventsPerNode ,
@@ -358,18 +362,44 @@ export class EndpointDocGenerator {
358362 * Creates an alert event and associated process ancestry. The alert event will always be the last event in the return array.
359363 * @param alertAncestors - number of ancestor generations to create
360364 */
361- public createAlertEventAncestry ( alertAncestors = 3 ) : Event [ ] {
365+ public createAlertEventAncestry (
366+ alertAncestors = 3 ,
367+ relatedEventsPerNode = 5 ,
368+ pctWithRelated = 30
369+ ) : Event [ ] {
362370 const events = [ ] ;
363371 const startDate = new Date ( ) . getTime ( ) ;
364372 const root = this . generateEvent ( { timestamp : startDate + 1000 } ) ;
365373 events . push ( root ) ;
366374 let ancestor = root ;
375+ // generate related alerts for root
376+ const processDuration : number = 6 * 3600 ;
377+ if ( this . randomN ( 100 ) < pctWithRelated ) {
378+ for ( const relatedEvent of this . relatedEventsGenerator (
379+ ancestor ,
380+ relatedEventsPerNode ,
381+ processDuration
382+ ) ) {
383+ events . push ( relatedEvent ) ;
384+ }
385+ }
367386 for ( let i = 0 ; i < alertAncestors ; i ++ ) {
368387 ancestor = this . generateEvent ( {
369388 timestamp : startDate + 1000 * ( i + 1 ) ,
370389 parentEntityID : ancestor . process . entity_id ,
371390 } ) ;
372391 events . push ( ancestor ) ;
392+
393+ // generate related alerts for ancestor
394+ if ( this . randomN ( 100 ) < pctWithRelated ) {
395+ for ( const relatedEvent of this . relatedEventsGenerator (
396+ ancestor ,
397+ relatedEventsPerNode ,
398+ processDuration
399+ ) ) {
400+ events . push ( relatedEvent ) ;
401+ }
402+ }
373403 }
374404 events . push (
375405 this . generateAlert (
0 commit comments