From 6f5ad45ba44734c132f38abb32a3f5a99f2d16ab Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Fri, 8 Sep 2023 12:48:49 -0700 Subject: [PATCH] revert naming convention change for bucket level monitors Signed-off-by: Surya Sashank Nistala --- .../transport/TransportIndexDetectorAction.java | 2 +- .../resthandler/DetectorMonitorRestApiIT.java | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java index 98ac07585..4da4577f6 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java @@ -850,7 +850,7 @@ private IndexMonitorRequest createBucketLevelMonitorRequest( triggers.add(bucketLevelTrigger1); } **/ - Monitor monitor = new Monitor(monitorId, Monitor.NO_VERSION, detector.getName() + UUID.randomUUID(), false, detector.getSchedule(), detector.getLastUpdateTime(), null, + Monitor monitor = new Monitor(monitorId, Monitor.NO_VERSION, detector.getName(), false, detector.getSchedule(), detector.getLastUpdateTime(), null, MonitorType.BUCKET_LEVEL_MONITOR, detector.getUser(), 1, bucketLevelMonitorInputs, triggers, Map.of(), new DataSources(detector.getRuleIndex(), detector.getFindingsIndex(), diff --git a/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java index 36595d07c..614d4ee11 100644 --- a/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java @@ -1607,17 +1607,6 @@ public void testCreateDetector_verifyWorkflowExecutionMultipleBucketLevelDocLeve String workflowId = ((List) detectorMap.get("workflow_ids")).get(0); HashMap bucketMonitorsToRuleMap = (HashMap) detectorMap.get("bucket_monitor_id_rule_id"); - String docMonitorId = bucketMonitorsToRuleMap.get("-1"); - String chainedFindingsMonitorId = bucketMonitorsToRuleMap.get("chained_findings_monitor"); - Map monitorNameToIdMap = new HashMap<>(); - for (Map.Entry entry : bucketMonitorsToRuleMap.entrySet()) { - Response getMonitorRes = getAlertingMonitor(client(), entry.getValue()); - Map resMap = asMap(getMonitorRes); - Map stringObjectMap = (Map) resMap.get("monitor"); - String name = stringObjectMap.get("name").toString(); - monitorNameToIdMap.put(name, entry.getValue()); - } - Response executeResponse = executeAlertingWorkflow(workflowId, Collections.emptyMap()); @@ -1626,13 +1615,10 @@ public void testCreateDetector_verifyWorkflowExecutionMultipleBucketLevelDocLeve for (Map runResult : monitorRunResults) { String monitorName = runResult.get("monitor_name").toString(); - String monitorId = monitorNameToIdMap.get(monitorName); - if(monitorId.equals(docMonitorId)){ + if(monitorName.equals(detector.getName())){ int noOfSigmaRuleMatches = ((List>) ((Map) runResult.get("input_results")).get("results")).get(0).size(); // 5 prepackaged and 1 custom doc level rule assertEquals(6, noOfSigmaRuleMatches); - } else if(monitorId.equals(chainedFindingsMonitorId)) { - } else { Map trigger_results = (Map) runResult.get("trigger_results"); if (trigger_results.containsKey(maxRuleId)) {