Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correlation alerts #877

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.opensearch.securityanalytics.model;

import org.opensearch.commons.alerting.model.ActionExecutionResult;
import org.opensearch.commons.alerting.model.Alert;
import org.opensearch.commons.authuser.User;

import java.time.Instant;
import java.util.List;

/**
* Model for docs store in .opensearch-sap-correlation-alerts index.
* Correlation alerts are created when a detector finding triggers correlation
*/
public class CorrelationAlert {

private final String id;
private final Instant startTime;
private final Instant acknowledgedTime;
private final Instant lastNotificationTime;
private final Instant endTime;
private final String correlationId;
private final List<ActionExecutionResult> actionExecutionResult;
private final Integer version;
private final Integer schemaVersion;
private final String triggerName;
private final String triggerId;
private final String errorMessage;
private final List<String> correlatedFindingIds;
private final List<String> correlationRuleNames;
private final User user;
private final String severity;
private final Alert.State state;


public CorrelationAlert(String id, Instant startTime, Instant acknowledgedTime,
Instant lastNotificationTime, Instant endTime, String correlationId,
List<ActionExecutionResult> actionExecutionResult, Integer version, Integer schemaVersion,
String triggerName, String triggerId, String errorMessage,
List<String> correlatedFindingIds, List<String> correlationRuleNames, User user,
String severity, Alert.State state) {
this.id = id;
this.startTime = startTime;
this.acknowledgedTime = acknowledgedTime;
this.lastNotificationTime = lastNotificationTime;
this.endTime = endTime;
this.correlationId = correlationId;
this.actionExecutionResult = actionExecutionResult;
this.version = version;
this.schemaVersion = schemaVersion;
this.triggerName = triggerName;
this.triggerId = triggerId;
this.errorMessage = errorMessage;
this.correlatedFindingIds = correlatedFindingIds;
this.correlationRuleNames = correlationRuleNames;
riysaxen-amzn marked this conversation as resolved.
Show resolved Hide resolved
this.user = user;
this.severity = severity;
this.state = state;
}


}
123 changes: 123 additions & 0 deletions src/main/resources/mappings/correlation_alert_mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"mappings": {
"dynamic": "strict",
"_meta": {
"schema_version": 1
},
"properties": {
"acknowledged_time": {
"type": "date"
},
"action_execution_results": {
"type": "nested",
"properties": {
"action_id": {
"type": "keyword"
},
"last_execution_time": {
"type": "date"
},
"throttled_count": {
"type": "integer"
}
}
},
"end_time": {
"type": "date"
},
"error_message": {
"type": "text"
},
"correlated_finding_ids": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"id": {
"type": "keyword"
},
"last_notification_time": {
"type": "date"
},
"correlation_id": {
"type": "keyword"
},
"correlation_rule_name": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be correlation_rule_names? to remain consistent with CorrelationAlert

"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"user": {
"properties": {
"backend_roles": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"custom_attribute_names": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"roles": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
},
"schema_version": {
"type": "integer"
},
"severity": {
"type": "keyword"
},
"start_time": {
"type": "date"
},
"state": {
"type": "keyword"
},
"trigger_id": {
"type": "keyword"
},
"trigger_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"version": {
"type": "long"
}
}
}
}
Loading