Skip to content

Commit

Permalink
add related event generation to ancestor nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Kimmel committed Apr 30, 2020
1 parent 5887c97 commit f081e72
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions x-pack/plugins/endpoint/common/generate_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ export class EndpointDocGenerator {
percentNodesWithRelated?: number,
percentChildrenTerminated?: number
) {
const ancestry = this.createAlertEventAncestry(alertAncestors);
const ancestry = this.createAlertEventAncestry(
alertAncestors,
relatedEventsPerNode,
percentNodesWithRelated
);
for (let i = 0; i < ancestry.length; i++) {
yield ancestry[i];
}
Expand All @@ -350,18 +354,44 @@ export class EndpointDocGenerator {
* Creates an alert event and associated process ancestry. The alert event will always be the last event in the return array.
* @param alertAncestors - number of ancestor generations to create
*/
public createAlertEventAncestry(alertAncestors = 3): Event[] {
public createAlertEventAncestry(
alertAncestors = 3,
relatedEventsPerNode = 5,
pctWithRelated = 30
): Event[] {
const events = [];
const startDate = new Date().getTime();
const root = this.generateEvent({ timestamp: startDate + 1000 });
events.push(root);
let ancestor = root;
// generate related alerts for root
const processDuration: number = 6 * 3600;
if (this.randomN(100) < pctWithRelated) {
for (const relatedEvent of this.relatedEventsGenerator(
ancestor,
relatedEventsPerNode,
processDuration
)) {
events.push(relatedEvent);
}
}
for (let i = 0; i < alertAncestors; i++) {
ancestor = this.generateEvent({
timestamp: startDate + 1000 * (i + 1),
parentEntityID: ancestor.process.entity_id,
});
events.push(ancestor);

// generate related alerts for ancestor
if (this.randomN(100) < pctWithRelated) {
for (const relatedEvent of this.relatedEventsGenerator(
ancestor,
relatedEventsPerNode,
processDuration
)) {
events.push(relatedEvent);
}
}
}
events.push(
this.generateAlert(
Expand Down

0 comments on commit f081e72

Please sign in to comment.