Skip to content

Commit 1b36aa1

Browse files
authored
enabled findings in bucket level monitor creation (opensearch-project#131)
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
1 parent 2f0abe6 commit 1b36aa1

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ private IndexMonitorRequest createBucketLevelMonitorRequest(
474474
detector.getAlertsHistoryIndex(),
475475
detector.getAlertsHistoryIndexPattern(),
476476
DetectorMonitorConfig.getRuleIndexMappingsByType(detector.getDetectorType()),
477-
false), PLUGIN_OWNER_FIELD);
477+
true), PLUGIN_OWNER_FIELD);
478478

479479
return new IndexMonitorRequest(monitorId, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, refreshPolicy, restMethod, monitor, null);
480480
}

src/test/java/org/opensearch/securityanalytics/resthandler/DetectorRestApiIT.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ public void testCreatingADetectorWithAggregationRules() throws IOException {
318318

319319
Response executeResponse = executeAlertingMonitor(bucketLevelMonitorId, Collections.emptyMap());
320320
Map<String, Object> executeResults = entityAsMap(executeResponse);
321-
// TODO - check findings
321+
// verify bucket level monitor findings
322+
Map<String, String> params = new HashMap<>();
323+
params.put("detector_id", createdRuleId);
324+
Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null);
325+
Map<String, Object> getFindingsBody = entityAsMap(getFindingsResponse);
326+
assertNotNull(getFindingsBody);
327+
Assert.assertEquals(1, getFindingsBody.get("total_findings"));
322328
}
323329
public void testUpdateADetector() throws IOException {
324330
String index = createTestIndex(randomIndex(), windowsIndexMapping());

0 commit comments

Comments
 (0)