Skip to content

Commit

Permalink
revert naming convention change for bucket level monitors
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <[email protected]>
  • Loading branch information
eirsep committed Sep 8, 2023
1 parent ea025b0 commit 6f5ad45
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1607,17 +1607,6 @@ public void testCreateDetector_verifyWorkflowExecutionMultipleBucketLevelDocLeve
String workflowId = ((List<String>) detectorMap.get("workflow_ids")).get(0);

HashMap<String, String> bucketMonitorsToRuleMap = (HashMap<String, String>) detectorMap.get("bucket_monitor_id_rule_id");
String docMonitorId = bucketMonitorsToRuleMap.get("-1");
String chainedFindingsMonitorId = bucketMonitorsToRuleMap.get("chained_findings_monitor");
Map<String, String> monitorNameToIdMap = new HashMap<>();
for (Map.Entry<String, String> entry : bucketMonitorsToRuleMap.entrySet()) {
Response getMonitorRes = getAlertingMonitor(client(), entry.getValue());
Map<String, Object> resMap = asMap(getMonitorRes);
Map<String, Object> stringObjectMap = (Map<String, Object>) resMap.get("monitor");
String name = stringObjectMap.get("name").toString();
monitorNameToIdMap.put(name, entry.getValue());
}


Response executeResponse = executeAlertingWorkflow(workflowId, Collections.emptyMap());

Expand All @@ -1626,13 +1615,10 @@ public void testCreateDetector_verifyWorkflowExecutionMultipleBucketLevelDocLeve

for (Map<String, Object> 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<String, Object>>) ((Map<String, Object>) 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<String, Object> trigger_results = (Map<String, Object>) runResult.get("trigger_results");
if (trigger_results.containsKey(maxRuleId)) {
Expand Down

0 comments on commit 6f5ad45

Please sign in to comment.