Skip to content

Commit

Permalink
add owner field in monitor (#110) (#111)
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
(cherry picked from commit 269be07)

Co-authored-by: Surya Sashank Nistala <snistala@amazon.com>
  • Loading branch information
opensearch-trigger-bot[bot] and eirsep committed Nov 4, 2022
1 parent c415338 commit ad18056
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

public class TransportIndexDetectorAction extends HandledTransportAction<IndexDetectorRequest, IndexDetectorResponse> {

public static final String PLUGIN_OWNER_FIELD = "security_analytics";
private static final Logger log = LogManager.getLogger(TransportIndexDetectorAction.class);

private final Client client;
Expand Down Expand Up @@ -190,7 +191,7 @@ private void createAlertingMonitorFromQueries(Pair<String, List<Pair<String, Rul
detector.getAlertsHistoryIndex(),
detector.getAlertsHistoryIndexPattern(),
DetectorMonitorConfig.getRuleIndexMappingsByType(detector.getDetectorType()),
true));
true), PLUGIN_OWNER_FIELD);

IndexMonitorRequest indexMonitorRequest = new IndexMonitorRequest(Monitor.NO_ID, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, refreshPolicy, RestRequest.Method.POST, monitor, null);
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, indexMonitorRequest, namedWriteableRegistry, listener);
Expand Down Expand Up @@ -242,7 +243,7 @@ private void updateAlertingMonitorFromQueries(Pair<String, List<Pair<String, Rul
detector.getAlertsHistoryIndex(),
detector.getAlertsHistoryIndexPattern(),
DetectorMonitorConfig.getRuleIndexMappingsByType(detector.getDetectorType()),
true));
true), PLUGIN_OWNER_FIELD);

IndexMonitorRequest indexMonitorRequest = new IndexMonitorRequest(detector.getMonitorIds().get(0), SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, refreshPolicy, RestRequest.Method.PUT, monitor, null);
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, indexMonitorRequest, namedWriteableRegistry, listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.opensearch.securityanalytics.action.GetDetectorResponse;
import org.opensearch.securityanalytics.config.monitors.DetectorMonitorConfig;
import org.opensearch.securityanalytics.model.Detector;
import org.opensearch.securityanalytics.transport.TransportIndexDetectorAction;
import org.opensearch.test.OpenSearchTestCase;


Expand Down Expand Up @@ -89,7 +90,8 @@ public void testGetAlerts_success() {
List.of(),
List.of(),
Map.of(),
new DataSources()
new DataSources(),
TransportIndexDetectorAction.PLUGIN_OWNER_FIELD
),
new DocumentLevelTrigger("trigger_id_1", "my_trigger", "severity_low", List.of(), new Script("")),
List.of("finding_id_1"),
Expand Down Expand Up @@ -119,7 +121,8 @@ public void testGetAlerts_success() {
List.of(),
List.of(),
Map.of(),
new DataSources()
new DataSources(),
TransportIndexDetectorAction.PLUGIN_OWNER_FIELD
),
new DocumentLevelTrigger("trigger_id_1", "my_trigger", "severity_low", List.of(), new Script("")),
List.of("finding_id_1"),
Expand Down

0 comments on commit ad18056

Please sign in to comment.